[BUG] Bedrock Opus 4.6 incorrectly gets 200k context window instead of 1M
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using Claude Opus 4.6 via AWS Bedrock (us.anthropic.claude-opus-4-6-v1), Claude Code reports a 200k context window, auto-compacts at the 200k threshold, and hits the "Context limit reached" blocking limit prematurely. AWS Bedrock natively supports 1M context for this model without requiring any beta headers.
The root cause is in the internal contextWindow calculation. The 1M path is gated on two conditions, both of which fail for Bedrock:
- Regex check (
/\[1m\]/i) — tests if the model string contains the literal text[1m]. No real model ID contains this. - Beta flag check — requires
sdkBetasto include"context-1m-2025-08-07", butsdkBetasis never populated for Bedrock providers since Bedrock doesn't use Anthropic SDK beta headers.
The model identification function correctly recognizes opus-4-6 in the Bedrock model ID, but it's only evaluated in conjunction with the beta flag:
// Simplified from minified source (v2.1.87)
function getContextWindow(model, betas) {
// Path 1: regex /\[1m\]/i — doesn't match any real model ID
if (regexCheck(model)) return 1_000_000;
// Path 2: registry lookup — falls through if model not in registry
let info = registryLookup(model);
if (info?.max_input_tokens >= 100_000) {
if (info.max_input_tokens > 200_000 && disable1MContext()) return 200_000;
return info.max_input_tokens;
}
// Path 3: requires BOTH beta flag AND model match — betas is undefined for Bedrock
if (betas?.includes("context-1m-2025-08-07") && isOpusOrSonnet4(model))
return 1_000_000;
return 200_000; // default fallback — this is what Bedrock Opus hits
}
This cascades into two additional problems:
CLAUDE_CODE_AUTO_COMPACT_WINDOWcannot override upward: The env var is applied viaMath.min(contextWindow, override), so setting it to 1M results inMath.min(200000, 1000000) = 200000. It can only make the window smaller.- Blocking limit is too low: The "Context limit reached" blocking limit is calculated as
contextWindow - reserved - 3000 ≈ 177k, preventing use of the full 1M context.
What Should Happen?
Bedrock Opus 4.6 (us.anthropic.claude-opus-4-6-v1) should be recognized as having a 1M context window. The isOpusOrSonnet4(model) check (which already correctly identifies Bedrock model IDs containing opus-4-6) should be sufficient to return 1M without requiring the beta flag, since Bedrock supports 1M natively.
/contextshould show 1M for Bedrock Opus 4.6- Auto-compact should trigger at the 1M boundary, not 200k
CLAUDE_CODE_AUTO_COMPACT_WINDOWshould useMath.max(or replace) instead ofMath.minso users can override the detected window upward
Error Messages/Logs
/context output showing 200k:
⛁ ⛁ ⛀ ⛀ ⛀ ⛀ ⛶ ⛶ ⛶ ⛶ us.anthropic.claude-opus-4-6-v1 · 7k/200k tokens (4%)
Status line shows "0% until auto-compact" and eventually:
Context limit reached · /compact or /clear to continue · /model opus
This occurs well before reaching the actual 1M Bedrock limit.
Steps to Reproduce
- Configure Claude Code to use AWS Bedrock with Opus 4.6:
``json``
{
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_REGION": "us-west-2",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "us.anthropic.claude-opus-4-6-v1"
},
"model": "opus"
}
- Start a conversation
- Run
/context— observe it shows 200k instead of 1M - Use the conversation until ~177k tokens — observe "Context limit reached" blocking message appears
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Other
Additional Information
- Claude Code version: 2.1.87
- OS: macOS (Darwin 25.3.0)
- Bedrock model ID:
us.anthropic.claude-opus-4-6-v1(cross-region inference profile) - Workarounds:
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=950000— prevents the "Context limit reached" block until ~950k tokens (this env var uses direct replacement instead ofMath.min)CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000— does NOT help due toMath.min, but doesn't hurt/contextdisplay will still show 200k incorrectly regardless of workarounds- The same issue likely affects any Bedrock model that supports >200k context, including Sonnet 4.6 if it has extended context on Bedrock, not fully tested yet.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗