Skip to content

fix(streaming): accumulate compaction_delta content and add JSON parse error context#1665

Open
yen0304 wants to merge 1 commit into
anthropics:mainfrom
yen0304:fix-compaction-delta-accumulation
Open

fix(streaming): accumulate compaction_delta content and add JSON parse error context#1665
yen0304 wants to merge 1 commit into
anthropics:mainfrom
yen0304:fix-compaction-delta-accumulation

Conversation

@yen0304

@yen0304 yen0304 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • Beta streaming: compaction_delta handler 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 by text_delta and thinking_delta in the same file.
  • GA streaming: from_json() for input_json_delta lacked the try/except that the Beta path already has. When the model produces malformed JSON, GA users got a raw ValueError with no context instead of the helpful message the Beta path provides.

…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.
@yen0304 yen0304 requested a review from a team as a code owner June 9, 2026 02:35
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