Skip to content

fix(openrouter): disable Claude Code tool search for OpenRouter sessions - #79

Merged
gfsaaser24 merged 1 commit into
turbofrom
fix/openrouter-tool-search
Aug 18, 2026
Merged

fix(openrouter): disable Claude Code tool search for OpenRouter sessions#79
gfsaaser24 merged 1 commit into
turbofrom
fix/openrouter-tool-search

Conversation

@gfsaaser24

Copy link
Copy Markdown
Owner

Any OpenRouter turn on a non-Anthropic model failed with:

400 Deferred custom tools are only supported on Anthropic models.
Non-Anthropic models cannot call tools omitted from tools[].
Received moonshotai/kimi-k3-20260715.

Claude Code defaults to tool search: it omits tools from tools[] and refers to them with tool_reference blocks. 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:

if (!K.ENABLE_TOOL_SEARCH && !l3o() && Yn() === "firstParty" && !qf()) return false

Once ANTHROPIC_AUTH_TOKEN carries the OpenRouter key that is no longer the case, so the guard never triggered and tool search stayed on.

Fix: set ENABLE_TOOL_SEARCH=false in the OpenRouter process env. That is Claude Code's own off switch — its parser maps false to "standard" mode, which returns false from the tool-search gate. An explicit host value still wins, for proxies that do forward tool_reference blocks; a blank host value falls back to the OpenRouter default.

Tests cover both the default and the host override.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f3d5d10e-7aee-4799-a5d9-efdf612bcbc5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Aug 18, 2026
@github-actions

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 12.6 KiB 15.1 KiB
Codex Thread snapshot wire 6.3 KiB 7.3 KiB
Codex Live turn WebSocket wire 6.3 KiB 7.8 KiB
Codex Live turn WebSocket decoded 51.8 KiB 66.4 KiB
Codex Live turn messages 16 21
Claude Total thread wire 12.6 KiB 15.1 KiB
Claude Thread snapshot wire 6.3 KiB 7.3 KiB
Claude Live turn WebSocket wire 6.3 KiB 7.8 KiB
Claude Live turn WebSocket decoded 52.7 KiB 66.4 KiB
Claude Live turn messages 16 21

Baseline: unavailable · PR result: f9ff460 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 99.9 KiB
  • Claude decoded thread snapshot: 100.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@gfsaaser24
gfsaaser24 merged commit 4f4217b into turbo Aug 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant