You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Beta header context-1m-2025-08-07 not sent for Claude Opus 4.6, causing 200k hard limit #12507
Claude Opus 4.6 supports a 1M token context window, but the Anthropic API requires the beta header context-1m-2025-08-07 to unlock it. Without this header, the API enforces a hard 200k input token limit.
OpenCode currently sends this beta header for claude-sonnet-* models but does not include claude-opus-4-6. This causes the API to reject requests exceeding 200k tokens:
prompt is too long: 201965 tokens > 200000 maximum
Root Cause
The beta header logic only matches Sonnet model IDs. Opus 4.6 is the first Opus-class model with 1M context support and needs to be added to the header inclusion check.
Impact
Config overrides setting limit.context: 1000000 have no effect — the limit is enforced server-side by the Anthropic API
The status bar shows usage against 1M (e.g., 11% at 109k tokens), but the API rejects at 200k
Auto compaction doesn't trigger in time because OpenCode believes the model has 1M of headroom
Expected Behavior
OpenCode should send anthropic-beta: context-1m-2025-08-07 header for claude-opus-4-6 requests, matching the behavior already in place for Sonnet models.
For Anthropic direct API users, I made a plugin that injects the context-1m-2025-08-07 beta header via chat.headers hook — it appends to existing SDK beta flags (claude-code, interleaved-thinking, etc.) instead of replacing them.
The plugin entry injects the beta header. The provider.anthropic.models entries override the default 200K limit so auto-compaction triggers at ~968K instead of ~168K.
Activity
github-actions commentedon Feb 6, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
ItsWendell commentedon Feb 16, 2026
Here's a workaround that worked for me: #12338 (comment)
DusKing1 commentedon Mar 7, 2026
For Anthropic direct API users, I made a plugin that injects the
context-1m-2025-08-07beta header viachat.headershook — it appends to existing SDK beta flags (claude-code, interleaved-thinking, etc.) instead of replacing them.Add to your
opencode.json:{ "plugin": ["opencode-anthropic-context-1m"], "provider": { "anthropic": { "models": { "claude-opus-4-6": { "limit": { "context": 1000000, "output": 128000 } }, "claude-sonnet-4-6": { "limit": { "context": 1000000, "output": 64000 } }, "claude-sonnet-4-5": { "limit": { "context": 1000000, "output": 64000 } }, "claude-sonnet-4-20250514": { "limit": { "context": 1000000, "output": 64000 } } } } } }The
pluginentry injects the beta header. Theprovider.anthropic.modelsentries override the default 200K limit so auto-compaction triggers at ~968K instead of ~168K.Repo: https://github.com/DusKing1/opencode-anthropic-context-1m
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.