fix(streaming): accumulate compaction_delta content and add JSON parse error context#1665
Open
yen0304 wants to merge 1 commit into
Open
fix(streaming): accumulate compaction_delta content and add JSON parse error context#1665yen0304 wants to merge 1 commit into
yen0304 wants to merge 1 commit into
Conversation
…text for JSON parsing Two fixes for streaming event accumulation: 1. Beta streaming: compaction_delta handler replaced content instead of accumulating it. If compaction content is streamed across multiple deltas, all but the last chunk were lost. The TypeScript SDK correctly concatenates: `(content || '') + delta.content`. This aligns the Python SDK with that behavior and with the pattern used by text_delta and thinking_delta in the same file. 2. GA streaming: from_json() for input_json_delta lacked error handling that the Beta path already has. When the model produces malformed JSON, GA users got a raw ValueError with no context. Now surfaces the same helpful message as the Beta path.
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.
Summary
compaction_deltahandler used assignment (=) instead of accumulation (+=). If compaction content is streamed across multiple deltas, all but the last chunk were lost. The TypeScript SDK correctly concatenates:(content || '') + delta.content. This aligns with the pattern used bytext_deltaandthinking_deltain the same file.from_json()forinput_json_deltalacked the try/except that the Beta path already has. When the model produces malformed JSON, GA users got a rawValueErrorwith no context instead of the helpful message the Beta path provides.