🧭 fix: Migrate Anthropic Long Context#12911
Conversation
There was a problem hiding this comment.
Pull request overview
Migrates Anthropic long-context handling to GA behavior (Sonnet 4.6+/Opus 4.6+) by removing the retired context-1m-2025-08-07 beta header path, aligning context-window metadata, and simplifying pricing to standard rates for 1M-context Claude models.
Changes:
- Remove
context-1m-2025-08-07from direct Anthropic and Bedrock request wiring; keep only relevant remaining beta headers (e.g.,output-128k-2025-02-19). - Update Claude context-window metadata: Sonnet 4 / 4.5 → 200K; Sonnet 4.6 and Opus 4.6+ → 1M.
- Remove Claude “premium long context” pricing entries and update unit/integration tests + examples accordingly.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/data-schemas/src/methods/tx.ts | Adds Sonnet 4.5 standard pricing/cache rates; removes Claude premium long-context pricing entries. |
| packages/data-schemas/src/methods/tx.spec.ts | Updates premium pricing tests to use Gemini as the premium baseline; asserts Claude 1M GA models are standard-priced. |
| packages/data-schemas/src/methods/transaction.spec.ts | Updates premium-pricing integration tests to use gemini-3.1 and validates Claude 1M models are non-premium. |
| packages/data-schemas/src/methods/spendTokens.spec.ts | Updates spendTokens tests to remove Claude premium assertions and cover standard pricing above the former threshold. |
| packages/data-schemas/src/app/vertex.ts | Updates default Vertex Anthropic model example to claude-sonnet-4-6. |
| packages/data-provider/src/bedrock.ts | Refines supportsContext1m thresholding (Sonnet >=4.6); removes Bedrock injection of the retired context-1m beta header. |
| packages/data-provider/specs/bedrock.spec.ts | Updates Bedrock parsing tests to expect no context-1m beta header on Claude models. |
| packages/api/src/utils/tokens.ts | Adjusts Anthropic model context sizes (Sonnet 4 now 200K; adds Sonnet 4.5 at 200K). |
| packages/api/src/files/validation.ts | Updates documentation examples for Bedrock Claude 4+ model identifiers. |
| packages/api/src/endpoints/openai/config.anthropic.spec.ts | Removes expectation that Anthropic compatibility config sets the long-context beta header. |
| packages/api/src/endpoints/bedrock/initialize.spec.ts | Updates Bedrock initialization test expectations to drop the context-1m beta header. |
| packages/api/src/endpoints/anthropic/llm.spec.ts | Updates tests to assert promptCache works without setting long-context beta headers. |
| packages/api/src/endpoints/anthropic/helpers.ts | Removes the supportsContext1m header path for direct Anthropic requests. |
| packages/api/src/agents/transactions.bulk-parity.spec.ts | Updates premium-pricing parity tests to use gemini-3.1 instead of Claude. |
| librechat.example.yaml | Updates example configs to use claude-sonnet-4-6 and removes outdated model IDs. |
| api/utils/tokens.spec.js | Updates Claude token-limit tests for Sonnet 4.5 and for 4.6 > 4.5 context behavior. |
| .env.example | Updates example ANTHROPIC_MODELS list to remove claude-sonnet-4-20250514. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Matches Bedrock Claude 4+ model identifiers, including cross-region inference profile IDs. | ||
| * Pattern: [region.]anthropic.claude-{family}-{version≥4}-{date}-v{n}:{rev} |
GitNexus: 🚀 deployedThe |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
I migrated Anthropic long-context handling to the GA Sonnet 4.6 / Opus 4.6+ behavior and removed the retired 1M beta header path.
context-1m-2025-08-07header from direct Anthropic requests and Bedrockanthropic_betarequest fields.claude-sonnet-4-6.Change Type
Testing
npm run build:data-provider && npm run build:data-schemas && npm run build:apicd packages/data-provider && npx jest specs/bedrock.spec.ts --runInBand --coverage=falsecd packages/api && npx jest src/endpoints/anthropic/llm.spec.ts src/endpoints/openai/config.anthropic.spec.ts src/endpoints/bedrock/initialize.spec.ts src/agents/transactions.bulk-parity.spec.ts --runInBand --coverage=falsecd packages/data-schemas && npx jest src/methods/tx.spec.ts src/methods/spendTokens.spec.ts src/methods/transaction.spec.ts --runInBand --coverage=falsecd api && npx jest utils/tokens.spec.js --runInBand --coverage=falsegit diff --checkTest Configuration:
Checklist