Skip to content

Beta header context-1m-2025-08-07 not sent for Claude Opus 4.6, causing 200k hard limit #12507

Closed as not planned

Description

@ErcinDedeoglu

Problem

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.

Activity

  1. github-actions commented on Feb 6, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. ItsWendell commented on Feb 16, 2026

    @ItsWendell
    Contributor

    Here's a workaround that worked for me: #12338 (comment)

  3. DusKing1 commented on Mar 7, 2026

    @DusKing1

    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.

    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 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.

    Repo: https://github.com/DusKing1/opencode-anthropic-context-1m

  4. assigned and unassigned on Apr 26, 2026
  5. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions