fix(bedrock): report 1M context for Opus 4.6+/Sonnet 4.6 - #54901
fix(bedrock): report 1M context for Opus 4.6+/Sonnet 4.6#54901kilotone wants to merge 2 commits into
Conversation
The AnthropicBedrock client (build_anthropic_bedrock_client) attaches the context-1m-2025-08-07 beta unconditionally, so these models actually serve a 1M window on Bedrock. BEDROCK_CONTEXT_LENGTHS still reported 200K, causing context-usage accounting to under-report the real window. Bump Opus 4.6/4.7/4.8 and Sonnet 4.6 to 1M; older 3.x/Sonnet-4/Haiku stay at 200K. Ordering note added since get_bedrock_context_length picks the longest substring match.
There was a problem hiding this comment.
Pull request overview
Updates Hermes’ AWS Bedrock model metadata so context-window accounting matches the effective 1M context enabled by the Bedrock Anthropic SDK client headers for Claude Opus 4.6+ and Sonnet 4.6.
Changes:
- Bumped
BEDROCK_CONTEXT_LENGTHSforanthropic.claude-opus-4-6/4-7/4-8andanthropic.claude-sonnet-4-6from 200K to 1,000,000. - Added explanatory inline notes clarifying why these models should be treated as 1M on Bedrock.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Ordering matters: get_bedrock_context_length() picks the LONGEST matching | ||
| # substring, so more specific keys (e.g. "claude-opus-4-8") must precede the | ||
| # bare "claude-opus-4" / "claude-sonnet-4" fallbacks to win for an id like | ||
| # "us.anthropic.claude-opus-4-8". |
There was a problem hiding this comment.
Agreed, the wording was misleading — resolution is by longest matching key length, not insertion order. Rewrote the comment to say so explicitly (insertion order would only matter for same-length ties, which we don't have; keys are grouped specific-first purely for readability). Fixed in ea8038c.
| "anthropic.claude-opus-4-8": 1_000_000, | ||
| "anthropic.claude-opus-4-7": 1_000_000, | ||
| "anthropic.claude-opus-4-6": 1_000_000, | ||
| "anthropic.claude-sonnet-4-6": 1_000_000, |
There was a problem hiding this comment.
Correct — those assertions would have failed CI. Updated in ea8038c: test_claude_opus_4_6, test_claude_sonnet_versioned, and test_inference_profile_resolves now assert 1_000_000, plus added test_claude_opus_versioned_newer (opus-4-8) and a test_claude_sonnet_4_5_stays_200k regression guard. All 9 in TestBedrockContextLength pass locally.
Duplicate of #24059 — same |
…ng note Address Copilot review on NousResearch#54901: - Update TestBedrockContextLength assertions to 1M for opus-4-6/sonnet-4-6 (were still asserting 200K -> would fail CI). Add opus-4-8 and a sonnet-4-5-stays-200K regression guard. - Correct the misleading 'ordering matters' comment: resolution is by longest key length, independent of insertion order (ties aside).
|
Thanks — both points fixed in ea8038c:
|
|
Thanks — you're right that #24059 (@patrick-muller, 2026-05-11) predates this and covers the same core bump (opus-4-6/4-7 + sonnet-4-6 → 1M, with sonnet-4-5/haiku-4-5 staying 200K). I'm happy to defer to it as the canonical fix. One gap worth folding in before this is closed as a straight dupe: #24059's table does not include Suggestion: merge #24059 as the base and either cherry-pick the opus-4-8 line from here, or I can rebase #54901 down to just the opus-4-8 addition on top of #24059 so there's no overlap. Whatever's least work for the maintainer — I'll close this in favour of #24059 if you'd rather the opus-4-8 entry be added there directly. |
Unifying the Bedrock 1M-context PR familyI reviewed every open/closed PR touching The family (6 PRs, 2 concerns)
Two genuinely separate concerns
Recommended unified merge path (best-of, no redundant code)
Conclusion for this PR#54901's only deltas over #44861 were the |
Problem
BEDROCK_CONTEXT_LENGTHSreported 200K for Opus 4.6 / Sonnet 4.6, butbuild_anthropic_bedrock_client()attaches thecontext-1m-2025-08-07beta header unconditionally to theAnthropicBedrockclient used by the Bedrock provider (wired atagent/agent_init.py:653). These models actually serve a 1M window on Bedrock, so context-usage accounting under-reported the real window (the client requests 1M on the wire while the meter capped at 200K).Fix
Bump Opus 4.6/4.7/4.8 and Sonnet 4.6 to
1_000_000. Older 3.x / Sonnet-4 / Haiku models have no 1M support and stay at 200K.Added an ordering note:
get_bedrock_context_length()picks the longest matching substring, so specific keys (e.g.claude-opus-4-8) must precede the bareclaude-opus-4fallback for ids likeus.anthropic.claude-opus-4-8.Verification
build_anthropic_bedrock_client(anthropic_adapter.py:867) -> sends the 1M beta unconditionally; confirmed it is the client wired for the provider at agent_init.py:653./1Mforus.anthropic.claude-opus-4-8after the fix.