prompt is too long unrecoverable
Description
Opencode with Opus 4.5 often gives me prompt is too long: 209549 tokens > 200000 maximum. This is completely unrecoverable, short of rolling back the session or forking and you then need to compact or something.
Note I'm only at: 121,480 61% ($5.62)
OpenCode version
1.0.119
Steps to reproduce
Use Antropic api key with Opus 4.5, trigger a huge search for example in the primary agent.
Screenshot and/or share link
No response
Operating System
macos
Terminal
ghostty
This issue might be a duplicate of existing issues. Please check:
- #1092: AI_APICallError: prompt is too long - Nearly identical error with Opus model causing unrecoverable session state
- #164: AI_APICallError: prompt is too long & OAuth error - Exact same token overflow error (201082 > 200000) with Anthropic Opus
- #491: input length and 'max_tokens' exceed context limit - Same context window calculation issue with Anthropic models
- #2464: AT_APICallError: prompt token count exceeds limit - Similar token overflow blocking work (130389 > 128000)
- #3409: Opencode stuck after token too long - Token overflow causing stuck/unrecoverable state
- #1212: Fetched documentation exceeds context window limit - Context window overflow from tool outputs
- #4826: Is automatic tool calling output truncation supported? - Root cause discussion about tools generating huge outputs
All these issues share the same core problem: context window overflow leading to unrecoverable sessions. Feel free to ignore if your case has specific differences!
I had this happen today aswell when the main agent tried to webfetch the openrouter model list
% WebFetch https://openrouter.ai/api/v1/models
prompt is too long: 206917 tokens > 200000 maximum
@menoatree That URL returns over 450 kB of data for me, that must be around 100,000 tokens of context.
Yeah, see that #5360 issue where i added comments, there are tool calls like webfetch and mcp tools that are not truncated and if the source being webfetched or mcp tool scraped with something like firecrawl, it can easily cause the context window to be exceeded which results in this error with opus 4.5.