fix(claude): require routing takeover when 1M context marker is declared - #6791
fix(claude): require routing takeover when 1M context marker is declared#6791YusenZhang0601 wants to merge 3 commits into
Conversation
Enforce needsRouting: true for Claude Code providers that declare the [1M] context capability marker. When connecting to third-party Anthropic relay gateways, direct requests carrying [1M] in the model ID fail with 400/404 because upstream endpoints reject unrecognized model names. Routing through the local proxy ensures [1M] is stripped upstream while Claude Code retains the 1,000,000-token context window locally.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc1f5f9d4a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "ANTHROPIC_DEFAULT_FABLE_MODEL", | ||
| "CLAUDE_CODE_SUBAGENT_MODEL", |
There was a problem hiding this comment.
Include the legacy small-model override in the scan
When an existing provider stores its marked model in ANTHROPIC_SMALL_FAST_MODEL, this list reports no marker even though useModelState still reads that key as the fallback for the role models and the takeover backend explicitly recognizes it as a legacy model override. The provider therefore remains eligible for direct routing and can send the raw [1M] suffix to the relay, reproducing the 400/404 failure this change is intended to prevent; include this legacy key in the marker scan.
Useful? React with 👍 / 👎.
Summary / 概述
Fixes an issue where Claude Code configured with third-party Anthropic relay providers fails with
400 / 404 Model not foundwhen 1M context is enabled, or silently falls back to 200K when[1M]is removed.Details / 详情
[1M]model suffix (e.g.,claude-3-7-sonnet-20250219[1M]) to unlock 1,000,000-token context windows and ignoresCLAUDE_CODE_MAX_CONTEXT_TOKENSforclaude-*models.[1M]was toggled on an Anthropic-format provider,providerNeedsRouting("claude", provider)previously evaluated tofalse, allowing direct connections where Claude Code sent raw[1M]model IDs to third-party relay gateways, causing upstream400 / 404errors.providerNeedsRoutingto checkhasAnyClaudeOneMMarkeracross all model fields insettingsConfig.env. When[1M]is present,needsRoutingevaluates totrue, ensuring requests route through the local proxy wheremodel_mapper.rsstrips[1M]before forwarding to upstream gateways while preserving Claude Code's local 1M context.Related Issue / 关联 Issue
Closes #3679
Checklist / 检查清单
providerCapabilities.test.ts