fix(bedrock): add 1M context for Opus 4.6/4.7 + Sonnet 4.6, bump anthropic SDK for bearer-token auth - #26769
Conversation
…ropic SDK for bearer-token auth Bedrock supports 1M context natively for Opus 4.6, Opus 4.7, and Sonnet 4.6 via the Converse API. No beta header needed (the context-1m-2025-08-07 beta is only for Anthropic's direct API). The previous BEDROCK_CONTEXT_LENGTHS table was capped at 200k for these models, which silently truncated user sessions even when running on Bedrock. Also bumps anthropic SDK 0.86.0 -> 0.102.0 in tools/lazy_deps.py. The 0.86 release predates AWS_BEARER_TOKEN_BEDROCK support (the long-term API key auth method AWS shipped in late 2025) and raises 'could not resolve credentials from session' when bearer-token auth is configured. 0.102+ honors the env var. Tests updated: - test_claude_opus_4_6: 200k -> 1M - test_claude_opus_4_7: new (cross-region inference profile) - test_claude_sonnet_versioned: 200k -> 1M - test_inference_profile_resolves: 200k -> 1M Verified against working production config in OpenClaw deployment.
|
+1 — this PR unblocks our deployment. Currently configured with:
Failure mode pre-this-PR matches your "Reproduction (before this PR)" exactly: Also affects the auxiliary path independently (cross-link: #29309). The SDK bump in this PR fixes both surfaces in one change. The PR has been open for a week with the only blocker being the |
|
For anyone tracking bearer-token Bedrock support: the two PRs that look closest to a complete fix are #24507 (main-loop Converse routing + Relative to this PR: it fixes bearer auth by bumping the |
|
Update — the aux vision gap noted in my comment above is now resolved by #28085's second commit ( |
|
Thanks for identifying the stale Bedrock context metadata. The context-table premise remains valid on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
|
Resolved via PR #67977, which lands the same context-table flip (Opus 4.6/4.7 + Sonnet 4.6 → 1M) salvaged from the earliest submission in this cluster (#24059, May 11) plus Opus 4.8 from #54918. Your PR arrived five days after #24059 with the same table half, so that one was used as the base — but credit to you for the identical diagnosis. The SDK-bump / bearer-token half of your PR is tracked separately (overlaps #63650, still open). Thanks! |
Summary
Bedrock natively supports 1M context windows for Claude Opus 4.6, Opus 4.7, and Sonnet 4.6 via the Converse API — no beta header needed. The
context-1m-2025-08-07beta is only required on Anthropic's direct API, not on Bedrock.The current
BEDROCK_CONTEXT_LENGTHStable caps these models at 200k, which silently truncates user sessions even when running on Bedrock with plenty of headroom available. This PR fixes the table and adds the missing entry for Opus 4.7.Also bumps the pinned
anthropicSDK from0.86.0→0.102.0intools/lazy_deps.py. The 0.86 release predatesAWS_BEARER_TOKEN_BEDROCKsupport (the long-term API-key auth method AWS shipped in late 2025) and raisescould not resolve credentials from sessionwhenever bearer-token auth is configured.0.102+honors the env var. The two changes are coupled — without the SDK bump, Bedrock + bearer-token users can't reach the model at all to benefit from the larger context window.Changes
agent/bedrock_adapter.pyanthropic.claude-opus-4-7→1_000_000anthropic.claude-opus-4-6:200_000→1_000_000anthropic.claude-sonnet-4-6:200_000→1_000_000tests/agent/test_bedrock_adapter.pytest_claude_opus_4_6: assert1_000_000test_claude_opus_4_7: new — covers theus.anthropic.claude-opus-4-7cross-region inference profiletest_claude_sonnet_versioned: assert1_000_000test_inference_profile_resolves: assert1_000_000tools/lazy_deps.pyprovider.anthropic:anthropic==0.86.0→anthropic==0.102.0Reproduction (before this PR)
After SDK bump:
After both fixes: full 1M context active, bearer-token auth works.
Tests
Notes
context-1m-2025-08-07beta header path is unchanged; this PR only corrects the Bedrock side, which is independent.us.anthropic.claude-opus-4-7already resolve correctly via the existing longest-prefix matcher.