Skip to content

fix(bedrock): enable Claude 1M context metadata - #44419

Closed
alfredomtx wants to merge 1 commit into
NousResearch:mainfrom
alfredomtx:fix/bedrock-claude-long-context-metadata
Closed

alfredomtx wants to merge 1 commit into
NousResearch:mainfrom
alfredomtx:fix/bedrock-claude-long-context-metadata

Conversation

@alfredomtx

Copy link
Copy Markdown

Summary

  • update Bedrock Claude context metadata for 1M-capable Opus/Sonnet models
  • align get_bedrock_context_length() with versioned and inference-profile Claude IDs
  • send additionalModelRequestFields.anthropic_beta=["context-1m-2025-08-07"] on the Bedrock Converse path when the selected Claude model advertises >200K context
  • keep standard 200K Claude models from receiving the 1M beta

Why

Some Bedrock Claude routes require the 1M context beta field in the Converse request. Without it, Hermes can budget for a 1M context window but Bedrock still rejects prompts over 200K tokens.

This keeps metadata and request construction in sync.

Tests

  • python -m pytest tests/agent/test_bedrock_1m_context.py tests/agent/test_bedrock_adapter.py -q

Result: 130 passed

Review

  • Independent review flagged the missing Converse additionalModelRequestFields path; this PR now includes that fix and regression coverage.
  • AU inference-profile IDs are covered so 1M metadata and beta injection work for regional profile prefixes, not just us/global/eu.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/bedrock AWS Bedrock (boto3, IAM) P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 11, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Duplicate of #31309 — same fix (forward context-1m beta on the Bedrock Converse adapter via additionalModelRequestFields, #31277). #31309 is the earlier open PR.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants