fix: fire BetaInputJsonEvent for server_tool_use blocks during streaming#1442
Open
Zelys-DFKH wants to merge 2 commits intoanthropics:mainfrom
Open
fix: fire BetaInputJsonEvent for server_tool_use blocks during streaming#1442Zelys-DFKH wants to merge 2 commits intoanthropics:mainfrom
Zelys-DFKH wants to merge 2 commits intoanthropics:mainfrom
Conversation
…de_execution continuation This ensures streaming mode behaves consistently with non-streaming messages.create() when the model uses code_execution tools that require container_id on subsequent turns.
The input_json_delta event handler was checking for tool_use and mcp_tool_use but not server_tool_use, even though TRACKS_TOOL_INPUT already includes BetaServerToolUseBlock. This prevented consumers from observing server tool input (e.g. tool_search, web_search) as it streamed in. Include server_tool_use in the content-block type check to make event firing consistent with accumulation.
Author
|
Note: PR #1380 addresses the same issue in the non-beta layer (InputJsonEvent in _messages.py). This PR covers the beta layer (BetaInputJsonEvent in _beta_messages.py) plus a separate fix for container propagation. The two PRs operate on different code paths and don't conflict, but maintainers may want to review them together to ensure consistency across both APIs. |
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.
Issue
The input_json_delta event handler in lib/streaming/_beta_messages.py fires BetaInputJsonEvent for tool_use and mcp_tool_use blocks but not for server_tool_use, even though the API streams input_json_delta events for server tools the same way.
This is inconsistent with the TRACKS_TOOL_INPUT tuple, which already includes BetaServerToolUseBlock — so the SDK correctly accumulates the streamed input into content_block.input, but never fires the parsed event to consumers.
Solution
Include server_tool_use in the content-block type check on line 368:
Testing
All 16 beta messages streaming tests pass.