Repository navigation
Python: Keep pending Anthropic server tool calls as server_tool_use #9513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Shivam Sharma (ShivamSharma43)
wants to merge
3
commits into
microsoft:main
from
ShivamSharma43:fix/9478-anthropic-server-tool-use
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5035339
Python: Keep pending Anthropic server tool calls as server_tool_use
ShivamSharma43 a03b285
Python: Correlate Anthropic server tool calls with results in transcr…
ShivamSharma43 5a09876
Python: Keep streamed Anthropic server tool call input
ShivamSharma43 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shivam Sharma (@ShivamSharma43), the
stream=Truescenario from #9478 still loses the pending search's arguments. A streamedserver_tool_usestarts withinput={}, and its query arrives throughinput_json_delta, but_parse_contents_from_anthropicdiscards those deltas for server tools. This branch consequently replaysserver_tool_usewithinput={}after the local result, rather than the original query, leaving the deferred search without its input. Please retain and accumulate the hosted argument deltas while keeping the call informational-only, and add a streaming regression that checks the query in the next outgoing request. The new tests supply complete inputs up front and therefore miss this path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you're right: the streamed path dropped the hosted argument deltas. Fixed in 5a09876.
_parse_contents_from_anthropicnow keepsinput_json_deltachunks for aserver_tool_usecall that is parsed as a hosted function call. They are emitted ashosted=True,informational_only=Truefragments with the call'scall_idand an empty name, so the existing streaming merge accumulates them into the call (the same mechanism as client-sidetool_usedeltas). The call stays informational-only and is not invoked locally. Deltas for MCP and code execution calls are still skipped, since those map to their own content types.test_streaming_parallel_server_tool_use_replays_streamed_input. It streams a localtool_useplus aserver_tool_usethat starts withinput={}and gets its query through twoinput_json_deltachunks, runs the local tool, and asserts the second outgoing request replaysserver_tool_usewith{"query": "agent framework release"}next to the localtool_result. It fails on the previous head with{} == {'query': ...}.test_parse_contents_server_tool_use_input_json_delta_ignoredasserted the old dropping behavior, so it is replaced bytest_parse_contents_server_tool_use_input_json_delta_is_hosted_and_informational, plustest_parse_contents_mcp_and_code_execution_input_json_delta_ignoredfor the cases that are still skipped.test_concurrent_streams_isolate_tool_state_when_peer_failsnow expects the hosted stream's delta fragment, and also checks that the concurrent local stream's fragments are not marked hosted.