Repository navigation
fix(gateway): refuse a hop that would drop the tool a request requires - #233
Merged
Merged
Conversation
Claude Code runs each web search as its own request that carries only the server-side web_search tool and forces the model to use it. Converted for an upstream of another format (Bedrock, OpenAI, Gemini, ...), the server tool is dropped, so the model answered without searching and Claude Code passed that answer on as the search results, with no error anywhere. When the tool a request forces (tool_choice naming a tool, or requiring a tool call when every tool was dropped) cannot be sent in the upstream's format, that hop is not sent: the next upstream of the route is tried, and if none can take it the client gets a 400 saying which tool and which upstream (gw.convert.tool_unsendable, gw.convert.tools_unsendable). Server tools offered alongside others with tool_choice auto are still dropped and reported, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
fylorn
added a commit
that referenced
this pull request
Sep 29, 2026
Patch release for #233. - Bump the workspace version to 0.55.1 - release-notes/0.55.1.md The control-plane protocol (28) and the request store schema (22) are unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
Claude Code runs every web search as a separate request. It carries only the server-side
web_search_20250305tool, forces it withtool_choice: {type: "tool", name: "web_search"}, and reads the answer'sserver_tool_useandweb_search_tool_resultblocks. Any text in the answer also becomes part of the "results".When that request is converted for an upstream of another format (Bedrock Converse, OpenAI Chat or Responses, Gemini), the server tool is dropped, since only the provider it belongs to can run it. The forced
tool_choicethen has nothing to point at and is dropped too. The model answered the search prompt from memory, and Claude Code handed that text back as search results. No error was raised; the only trace was a "dropped" entry in the request details.What changes
hop.rsgetsunsendable_tool, called inprepareright after the request is encoded for the upstream's format. It refuses the hop when either of these holds:tool_choicenames a tool that is no longer among the tools sent (gw.convert.tool_unsendable, argstool,upstream), ortool_choicerequires a tool call, no tool is left, and tools were dropped (gw.convert.tools_unsendable, argupstream).A refused hop behaves like a conversion failure. It goes on the attempt chain, and the next upstream of the route is tried, since an upstream of the same format may come later. If none can take the request, the client gets a 400
invalid_request_errorthat names the tool and the upstream. Claude Code then shows the search as failed instead of passing on made-up results.Server tools offered with
tool_choice: autoalongside other tools are still dropped and reported. Some clients attach them to every request, and the conversation works without them.Tests
tests/dialect.rs:web_searchand the upstream. The upstream receives nothing, andRequestFailedcarriesgw.convert.tool_unsendable.web_searchoffered alongside other tools underautostill passes: the request is sent, and the drop is reported.cargo fmt --check,cargo clippy --workspace --all-targets -D warningsandcargo test --workspacepass locally.msg-codes.txtis updated.🤖 Generated with Claude Code