claude-code - 💡(How to fix) Fix claude-sonnet-4-6 /context reports 200K — same registry-stale bug already fixed for Opus 4.7 in v2.1.117 [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#58710Fetched 2026-05-14 03:41:29
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Code Example

ANTHROPIC_MODEL=claude-sonnet-4-6 \
ANTHROPIC_BASE_URL=<any backend that resolves the model> \
ANTHROPIC_API_KEY=<...> \
claude --bare -p --output-format stream-json --verbose <<< "$(printf 'pad %.0s' {1..100000}) reply with ok"
RAW_BUFFERClick to expand / collapse

Claude Code version: 2.1.140 (Windows native build)

What I expected

/context should show 1,000,000 for claude-sonnet-4-6.

Per the 2.1.49 changelog:

Sonnet 4.5 with 1M context is being removed from the Max plan in favor of our frontier Sonnet 4.6 model, which now has 1M context. Please switch in /model.

The same registry-stale bug was already fixed for Opus 4.7 in 2.1.117:

Fixed Opus 4.7 sessions showing inflated /context percentages and autocompacting too early — Claude Code was computing against a 200K context window instead of Opus 4.7's native 1M

That fix doesn't appear to extend to Sonnet 4.6.

What I actually see

With ANTHROPIC_MODEL=claude-sonnet-4-6 (no [1m] suffix), /context reports 200,000 and the modelUsage payload on every result event returns "contextWindow": 200000 regardless of actual input size.

Reproducer

ANTHROPIC_MODEL=claude-sonnet-4-6 \
ANTHROPIC_BASE_URL=<any backend that resolves the model> \
ANTHROPIC_API_KEY=<...> \
claude --bare -p --output-format stream-json --verbose <<< "$(printf 'pad %.0s' {1..100000}) reply with ok"

Inspect the result event's modelUsage["claude-sonnet-4-6"].contextWindow — value is 200000 even when inputTokens exceeds 200,000 and the request succeeded end-to-end.

Empirical confirmation the backend has 1M

A single -p call with inputTokens=321,901 returns rc=0 and the correct answer (model processed the full prompt). At inputTokens=385,833 in a separate test, also rc=0. Multi-turn probe via --continue accumulated content across 5 turns to ~250k user-content with no errors and no actual compaction events emitted in the stream-json. So the backend is honoring 1M; only Claude Code's internal registry is stale.

The CLAUDE_CODE_DISABLE_1M_CONTEXT env var (added in 2.1.50) was confirmed unset on the reporting environment, so the 200,000 value is not coming from that opt-out.

Impact

  1. /context and /usage display a misleading 200K cap.
  2. Auto-compaction calculations and skill character budget scale off contextWindow (per the changelog note "Skill character budget now scales with context window (2% of context)"). With a stale 200K registry, these subsystems under-allocate.
  3. Users who want the correct UI display fall back to ANTHROPIC_MODEL=claude-sonnet-4-6[1m] — but the [1m] suffix is a leftover marker from before Sonnet 4.6 went 1M-native, and downstream proxy routers may treat it as a separate alias rather than resolving it cleanly.

Suggested fix

Update Claude Code's model registry entry for claude-sonnet-4-6 to contextWindow: 1000000, mirroring the 2.1.117 fix for Opus 4.7. While doing so, worth verifying claude-opus-4-7 and any other recent model names don't have the same residue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix claude-sonnet-4-6 /context reports 200K — same registry-stale bug already fixed for Opus 4.7 in v2.1.117 [2 comments, 2 participants]