Skip to content

Forward response_id through StreamAccumulator to fix previous_response_id chaining - #14

Open
rustemmukhamadiev wants to merge 1 commit into
khasinski:mainfrom
rustemmukhamadiev:fix-response-id-lost-in-streaming
Open

rustemmukhamadiev wants to merge 1 commit into
khasinski:mainfrom
rustemmukhamadiev:fix-response-id-lost-in-streaming

Conversation

@rustemmukhamadiev

@rustemmukhamadiev rustemmukhamadiev commented Aug 31, 2026

Copy link
Copy Markdown

Note

Saw the same fix already sitting in #12, but that PR's been open since
June and looks blocked on a bigger native-RubyLLM migration. Opening this
as a small standalone fix so it can land sooner — would love to see it
merged independently rather than wait on #12.

Bug

When using streaming (chat.ask(message, &chunk_handler)), the response_id from
the completed response never survives into the persisted message, so
previous_response_id chaining never engages on the next turn.

Root cause

Streaming.build_chunk correctly attaches response_id to the
response.completed chunk, but RubyLLM::StreamAccumulator#to_message
(core gem) builds the final Message without it, and
StreamAccumulatorExtension only forwarded built_in_tool_events
through the accumulator, not response_id.

Non-streaming (chat.complete/chat.ask without a block) is unaffected.

Fix

Track response_id the same way built_in_tool_events already is:
capture it in add, apply it in to_message.

Verified locally: after the patch, a second streamed turn correctly
sends previous_response_id and only the new message in input,
instead of resending the whole history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant