Skip to content

🧭 fix: Migrate Anthropic Long Context#12911

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/fix-anthropic-sonnet-4-6
May 2, 2026
Merged

🧭 fix: Migrate Anthropic Long Context#12911
danny-avila merged 1 commit into
devfrom
danny-avila/fix-anthropic-sonnet-4-6

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

I migrated Anthropic long-context handling to the GA Sonnet 4.6 / Opus 4.6+ behavior and removed the retired 1M beta header path.

  • Removed the retired context-1m-2025-08-07 header from direct Anthropic requests and Bedrock anthropic_beta request fields.
  • Updated Claude context metadata so Sonnet 4 and Sonnet 4.5 resolve to 200K, while Sonnet 4.6 and Opus 4.6+ keep 1M.
  • Removed Claude long-context premium pricing entries now that 1M context uses standard pricing.
  • Pointed Vertex/default examples at claude-sonnet-4-6.
  • Updated Anthropic, Bedrock, token, and transaction pricing tests for the new model behavior.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Testing

  • Ran npm run build:data-provider && npm run build:data-schemas && npm run build:api
  • Ran cd packages/data-provider && npx jest specs/bedrock.spec.ts --runInBand --coverage=false
  • Ran cd 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=false
  • Ran cd packages/data-schemas && npx jest src/methods/tx.spec.ts src/methods/spendTokens.spec.ts src/methods/transaction.spec.ts --runInBand --coverage=false
  • Ran cd api && npx jest utils/tokens.spec.js --runInBand --coverage=false
  • Ran git diff --check

Test Configuration:

  • Node.js v20.19.5
  • npm 10.8.2

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings May 2, 2026 00:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-07 from 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.

Comment on lines 133 to 134
* Matches Bedrock Claude 4+ model identifiers, including cross-region inference profile IDs.
* Pattern: [region.]anthropic.claude-{family}-{version≥4}-{date}-v{n}:{rev}
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-12911 index is now live on the MCP server.
Deploy run

@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ 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".

@danny-avila
danny-avila merged commit eb22bb6 into dev May 2, 2026
19 checks passed
@danny-avila
danny-avila deleted the danny-avila/fix-anthropic-sonnet-4-6 branch May 2, 2026 13:14
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request May 3, 2026
jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants