Repository navigation
fix(llm): stream Bedrock ConverseStream events as they arrive - #167
Merged
Merged
Conversation
VladKhomich
force-pushed
the
fix/bedrock-converse-stream
branch
from
October 8, 2026 12:10
4232a73 to
f7622ad
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bedrock ConverseStream responses were buffered until the model finished, so callers received the entire answer in one burst. Parse and dispatch each event as bytes arrive. On wippy/llm 0.5.5 with Claude Haiku 4.5 in us-east-1 (three runs each), first-chunk latency changed from 9.7–12.7 seconds to about 1 second; chunks now arrive throughout the 10–12-second generation.
The reader also reports AWS exception messages through the existing error callback, skips every supported eventstream header value type without losing later headers, treats an empty read as pending data, and rejects a stream ending mid-frame. Impossible frame lengths fail immediately: a frame must include the 12-byte prelude and 4-byte CRC, and its headers must fit within that declared length. This prevents malformed zero-length frames from making the parser loop forever, including after a valid streamed event.
The InvokeModel path and public
(content, err, result)return contract are unchanged. CRC values remain unverified, as before.Validation: nine new streaming/parser tests cover per-event dispatch, split frames, empty reads, AWS exceptions, non-string headers, truncation, zero/undersized lengths, oversized headers, and malformed frames following valid content. The focused Bedrock client suite passes 13/13 tests; Bedrock namespace lint passes for 16 entries. Astra reviewed the frame-length follow-up and found no blockers. Full CI is rerunning on the updated branch.