Skip to content

[Bug]: Issue Report: Prompt exceeds model context limit - prompt is too long: 217905 tokens > 200000 maximum #1815

Closed

Description

@daheli

Prerequisites

  • I will write this issue in English (see our Language Policy)
  • I have searched existing issues to avoid duplicates
  • I am using the latest version of oh-my-opencode
  • I have read the documentation or asked an AI coding agent with this project's GitHub URL loaded and couldn't find the answer

Bug Description

Image Image

Steps to Reproduce

Issue Report: Prompt exceeds model context limit
Error
{
type: error,
error: {
type: invalid_request_error,
message: prompt is too long: 217905 tokens > 200000 maximum
},
request_id: req_vrtx_011CY5g2rB83xX4CoVEvdoHg
}
Description
The conversation prompt reached 217,905 tokens, exceeding the model's 200,000 token context limit. The API rejected the request with an invalid_request_error.

Model Configuration
{
antigravity-claude-opus-4-6-thinking: {
limit: {
context: 200000,
output: 64000
},
variants: {
max: { thinkingConfig: { thinkingBudget: 32768 } }
}
}
}
Root Cause Analysis
Total prompt token count of 217,905 exceeded the 200,000 limit by approximately 17,905 tokens (~9%). Contributing factors likely include:

  1. Large system prompt overhead — The oh-my-opencode Sisyphus agent system prompt is substantial, containing detailed behavioral instructions plus all tool definitions (Figma MCP ~15 tools + Chrome DevTools ~25 tools + opencode built-in tools).
  2. Conversation history accumulation — Multi-turn dialogue causes token count to grow monotonically without pruning.
  3. Figma MCP response payload — The get_metadata call returns verbose XML-formatted design tree data, which can be token-heavy.
  4. Thinking budget reservation — The thinkingBudget: 32768 may reduce effective available context for prompt content.
    Steps to Reproduce
  5. Configure antigravity-claude-opus-4-6-thinking as the Sisyphus agent model with context: 200000.
  6. Enable Figma MCP (figma-desktop) and Chrome DevTools MCP.
  7. Engage in a multi-turn conversation involving Figma MCP tool calls.
  8. After sufficient history accumulates (~200K tokens), the next request fails with the above error.

Expected Behavior

Expected Behavior
The system should gracefully handle conversations approaching the context limit — either by truncating/pruning older messages, warning the user, or automatically managing context window usage.

Actual Behavior

Actual Behavior
The request is rejected outright by the API with no prior warning or automatic mitigation.

Doctor Output

Environment
| Item | Value |
|------|-------|
| OS | macOS 15.5 (Build 24F74) |
| Architecture | arm64 (Apple M4 Max) |
| Node.js | v20.19.5 |
| npm | 10.8.2 |
| opencode-ai | 1.1.59 (global install) |
| @opencode-ai/plugin | 1.1.59 |
| oh-my-opencode | 3.5.2 |
| Active Model | google/antigravity-claude-opus-4-6-thinking (Sisyphus agent) |
| Configured Context Limit | 200,000 tokens |
| Configured Output Limit | 64,000 tokens |
| Thinking Budget (variant: max) | 32,768 tokens |
| Figma MCP | figma-desktop via http://127.0.0.1:3845/mcp (remote) |

Error Logs

Configuration

Additional Context

No response

Operating System

macOS

OpenCode Version

1.1.59

Activity

  1. aikazu commented on Feb 13, 2026

    @aikazu
    Image

    yep same, its happen since 4.6. trying workaround using experimental config mentioned it other issues, still same.

  2. ChoKhoOu commented on Feb 13, 2026

    @ChoKhoOu

    English

    The author has not been fixing it. Many issues have been raised, but it is useless; they do not care. I saw that someone seemed to have tried to fix this with a PR, but it was not accepted either.


    Original

    Image yep same, its happen since 4.6. trying workaround using experimental config mentioned it other issues, still same.

    作者一直没修,提了很多 issue 也没用,根本不管。我看好像有人提 PR 修这个,也没被接受。

  3. smashah commented on Feb 14, 2026

    @smashah

    which PR @ChoKhoOu
    ?

  4. code-yeongyu commented on Feb 16, 2026

    @code-yeongyu
    Owner

    [sisyphus-bot] Hi everyone! Thank you for reporting and discussing this issue.

    This is a friendly reminder that per our English-Only Policy, all GitHub communications (issues, PRs, comments) must be written in English. This helps ensure all contributors can participate and understand the discussions.

    I've added English translations to any non-English content above. Please use English for future comments on this issue.

    Thank you for your understanding and cooperation!

  5. code-yeongyu commented on Feb 17, 2026

    @code-yeongyu
    Owner

    Analysis: Root Cause Identified

    This is a confirmed bug affecting Claude Opus 4.6 users.

    Problem

    The plugin hardcodes a 200K context limit for all Anthropic models unless the ANTHROPIC_1M_CONTEXT=true environment variable is set. However, Claude Opus 4.6 natively supports 1M tokens.

    This causes:

    1. Preemptive compaction triggers at ~156K tokens (78% of 200K) instead of ~780K
    2. API rejects requests at 200K tokens (as seen: 217905 tokens > 200000 maximum)
    3. Users cannot utilize Opus 4.6's full 1M context capacity

    Evidence

    Current code in src/hooks/preemptive-compaction.ts and src/hooks/context-window-monitor.ts:

    const ANTHROPIC_ACTUAL_LIMIT =
      process.env.ANTHROPIC_1M_CONTEXT === "true" ||
      process.env.VERTEX_ANTHROPIC_1M_CONTEXT === "true"
        ? 1_000_000
        : 200_000  // ← Hardcoded for Opus 4.6

    The isOpus46() model detection exists in src/hooks/anthropic-effort/hook.ts but is not applied to the context window hooks.

    Fix Exists

    Commit f977423c contains the fix that adds isOpus46() check to both hooks:

    • Adds OPUS_4_6_LIMIT = 1_000_000 constant
    • Adds isOpus46(modelID) function for model detection
    • Uses model-aware limit: isOpus46(modelID) ? OPUS_4_6_LIMIT : ANTHROPIC_ACTUAL_LIMIT

    However, this fix is only in remotes/marlon/msc branch and not merged to the current release branch.

    Workaround

    Until the fix is merged, set this environment variable:

    export ANTHROPIC_1M_CONTEXT=true

    Then restart OpenCode. This will treat all Anthropic models as having 1M context.

    Related


    Recommendation: Cherry-pick or merge commit f977423 to resolve this issue.

  6. added a commit that references this issue on Feb 25, 2026
    fc1b6e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions