fix(openrouter): disable Claude Code tool search for OpenRouter sessions - #79
Conversation
Claude Code defaults to tool search, which omits tools from `tools[]` and refers to them with tool_reference blocks. OpenRouter's Anthropic-compatible endpoint rejects that for every non-Anthropic model, so any turn on a model like moonshotai/kimi-k3 died with: 400 Deferred custom tools are only supported on Anthropic models. Claude Code's own auto-disable only fires when the resolved auth kind is firstParty, which it is not once ANTHROPIC_AUTH_TOKEN carries the OpenRouter key, so the guard never triggered here. Set ENABLE_TOOL_SEARCH=false in the OpenRouter process env (Claude Code parses "false" into its off mode). An explicit host value still wins, for proxies that do forward tool_reference. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Any OpenRouter turn on a non-Anthropic model failed with:
Claude Code defaults to tool search: it omits tools from
tools[]and refers to them withtool_referenceblocks. OpenRouter's Anthropic-compatible endpoint rejects that for every non-Anthropic model.Claude Code does have an auto-disable for non-first-party base URLs, but reading the shipped CLI shows it only fires when the resolved auth kind is
firstParty:Once
ANTHROPIC_AUTH_TOKENcarries the OpenRouter key that is no longer the case, so the guard never triggered and tool search stayed on.Fix: set
ENABLE_TOOL_SEARCH=falsein the OpenRouter process env. That is Claude Code's own off switch — its parser mapsfalseto"standard"mode, which returnsfalsefrom the tool-search gate. An explicit host value still wins, for proxies that do forwardtool_referenceblocks; a blank host value falls back to the OpenRouter default.Tests cover both the default and the host override.
🤖 Generated with Claude Code