Skip to content

fix(claude): require routing takeover when 1M context marker is declared - #6791

Open
YusenZhang0601 wants to merge 3 commits into
farion1231:mainfrom
YusenZhang0601:fix/claude-1m-routing-takeover
Open

fix(claude): require routing takeover when 1M context marker is declared#6791
YusenZhang0601 wants to merge 3 commits into
farion1231:mainfrom
YusenZhang0601:fix/claude-1m-routing-takeover

Conversation

@YusenZhang0601

Copy link
Copy Markdown

Summary / 概述

Fixes an issue where Claude Code configured with third-party Anthropic relay providers fails with 400 / 404 Model not found when 1M context is enabled, or silently falls back to 200K when [1M] is removed.

Details / 详情

  1. Context Window Constraint: Claude Code strictly requires the [1M] model suffix (e.g., claude-3-7-sonnet-20250219[1M]) to unlock 1,000,000-token context windows and ignores CLAUDE_CODE_MAX_CONTEXT_TOKENS for claude-* models.
  2. Direct Connection Issue: When [1M] was toggled on an Anthropic-format provider, providerNeedsRouting("claude", provider) previously evaluated to false, allowing direct connections where Claude Code sent raw [1M] model IDs to third-party relay gateways, causing upstream 400 / 404 errors.
  3. Resolution: Updated providerNeedsRouting to check hasAnyClaudeOneMMarker across all model fields in settingsConfig.env. When [1M] is present, needsRouting evaluates to true, ensuring requests route through the local proxy where model_mapper.rs strips [1M] before forwarding to upstream gateways while preserving Claude Code's local 1M context.

Related Issue / 关联 Issue

Closes #3679

Checklist / 检查清单

  • TypeScript unit tests updated and verified in providerCapabilities.test.ts
  • Clean, minimal, and targeted changes without breaking schema changes

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.
@github-actions github-actions Bot added the frontend Frontend (React/TypeScript) label Aug 25, 2026
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +125 to +126
"ANTHROPIC_DEFAULT_FABLE_MODEL",
"CLAUDE_CODE_SUBAGENT_MODEL",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Frontend (React/TypeScript)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Claude 1M context marker fails: uppercase [1M] written + fallback model lacks toggle

2 participants