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
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.
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!
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.
I created https://github.com/ogyr/opencode-cullto today as a workaround. It lets you cull your current session (or select one) to a specified token limit. Works from within opencode when the session is still responsive, or as a standalone CLI that lists all sessions to choose from, then reopens opencode with the culled session. Works well enough for my use case.
In my cases, I switch the model to GLM5-Free (or another model with a large context windows) and compact session multiple times. ( I did until it’s under 10K tokens.) I lost a detail of the context little bit, but at least I can recover the session from the deadlock, and can use the Anthropic opus model again.
Still, it need to be fix. it seems this happens when I switch to a model whose context window is smaller than the current session's token count. Trimming might sliced out the the middle of the session data, There should be a exception handling on the compacting sequence.
Activity
github-actions commentedon Nov 27, 2025
This issue might be a duplicate of existing issues. Please check:
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!
menoatree commentedon Dec 12, 2025
I had this happen today aswell when the main agent tried to webfetch the openrouter model list
Nindaleth commentedon Dec 18, 2025
@menoatree That URL returns over 450 kB of data for me, that must be around 100,000 tokens of context.
ben-vargas commentedon Dec 19, 2025
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.
thdxr commentedon Dec 30, 2025
will be fixing this next week
PeterHa-UoH commentedon Jan 6, 2026
has it been fixed yet/
Nindaleth commentedon Jan 6, 2026
@PeterHa-UoH
I would say yes, but feel free to try it on your own
12 remaining items
miguelangelmorenochacon commentedon Feb 10, 2026
Happening with Opus 4.6
ashaychangwani commentedon Feb 11, 2026
Can we please reopen this issue? A lot of people are reporting the same in #5360
rekram1-node commentedon Feb 11, 2026
I found some places we had issues, fixing
daheli commentedon Feb 13, 2026
Same issue
code-yeongyu/oh-my-openagent#1815
smashah commentedon Feb 14, 2026
The whole payload seems to be filled with tool definitions
ogyr commentedon Feb 14, 2026
Same problem here with opus 4.6
/compact fails as well. I could live with a simple "How much of the oldest content do you want to trim? In k tokens"
iamtekeste commentedon Feb 15, 2026
Is there a workaround in the meantime?
ogyr commentedon Feb 15, 2026
I created https://github.com/ogyr/opencode-cullto today as a workaround. It lets you cull your current session (or select one) to a specified token limit. Works from within opencode when the session is still responsive, or as a standalone CLI that lists all sessions to choose from, then reopens opencode with the culled session. Works well enough for my use case.
drchopinfrederic commentedon Feb 19, 2026
In my cases, I switch the model to GLM5-Free (or another model with a large context windows) and compact session multiple times. ( I did until it’s under 10K tokens.) I lost a detail of the context little bit, but at least I can recover the session from the deadlock, and can use the Anthropic opus model again.
Still, it need to be fix. it seems this happens when I switch to a model whose context window is smaller than the current session's token count. Trimming might sliced out the the middle of the session data, There should be a exception handling on the compacting sequence.
zulufoxtrot commentedon Mar 23, 2026
I'm having the same problem.
Model: Qwen3.5 122B A10B 6bit. Default context window.
Backend: oMLX
Frontend: Opencode GUI 1.2.26 (note: Opencode CLI not installed)
Tool calls / MCPs: default
I did not switch models / agents during the session.
dlasher commentedon May 20, 2026
Seeing this as well, doesn't seem to depend on the model, breaks a bit over 300k in size.
github-actions commentedon Jul 20, 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.