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
Was there a tool call just before that? If that was the case, the result of the tool call must have been large. Your only option is to run /undo and then add an additional guidance to the agent to be more careful.
I'm gonna make it more resilient to these things soon, @arsham nails it w/ suggestion but ofc this isn't really an "acceptable" ux for you guys and that's on us. Will be better soon!
Reacted by Arsham Shirvani, Michael Vessia, Justin Carlson and Erik James Fritsch
I haven't seen this much lately, things have been fantastic... but today suddenly it's happened now three times in a row doing different tasks. Did anything change recently?
The other session is in a weird state now because it's the one I tried to fix. This is exactly the same thing I was working on Friday / Saturday though and haven't seen this issue before, now it keeps happening left and right.
Yeah, I'm running into similar error a ton, haven't been able to reliably use opencode for a few versions now. This is on the latest v1.0.164 and there was a firecrawl scrape right before truncation failed to work?
Also running into this a lot.
It's definitely large tool calls that are devouring context.
Probably because of bd (but it's so good).
Model: Anthropic/Claude Opus 4.5
If I switch model to Gemini, it's fine (mostly).
Truncation isn't aggressive enough, I think.
Cleaned up JSON from my session showing where it all went wrong.
[
{
info: {id: msg_b3475413b001geGkBJYoGtUd0o,role: assistant,modelID: claude-opus-4-5,tokens: {input: 6,output: 10586,cache: { read: 68795, write: 12195 }
},finish: tool-calls},parts: [
{
type: reasoning,text: Good, test file cleaned up. Now I need to push these commits to the PR and update the PR.
},
{
type: tool,tool: bash,state: {status: completed,input: {command: git push 2>&1,description: Push cleanup commits,env: {/* ... [21,965 character-indexed entries truncated] ... */CI: true,DEBIAN_FRONTEND: noninteractive,GIT_TERMINAL_PROMPT: 0,GCM_INTERACTIVE: never,HOMEBREW_NO_AUTO_UPDATE: 1
}
},output: To https://github.com/justcarlson/dotfiles.git\n d263a20..f890276 feat/beads-init -> feat/beads-init\n,time: {start: 1766111786187,end: 1766111786842}}}
]
},
{
info: {id: msg_b3477378e001PSDz7CbpYGme0T,role: assistant,error: {name: APIError,data: {message: prompt is too long: 212032 tokens > 200000 maximum,statusCode: 400,responseBody: {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 212032 tokens > 200000 maximum"},"request_id":"req_011CWFGUE8UeR24su49Cs3jB"}}}},parts: []}]...
I didn't post it here, but I did in a thread on their discord... my root cause (at least for my issue) is non-truncated mcp tool calls dumping too much into the context window. There should be a truncation of mcp and all tools, similar to the 30k limit on bash/internal tools.
I created a personal fix, but haven't PR'd it because opencode maintainers should probably weigh in on how they want to address this (truncation vs something like claude does - detailed below).
Claude Code has a unique way of handling really large bash outputs that I noticed... I asked it to explain the approach:
When a tool result is too large, Claude Code:
1. Persists the full output to a file in the session folder:
/Users/ben/.claude/projects/.../tool-results/mcp-firecrawl-firecrawl_scrape-1765980251222.txt
2. Returns a helpful message to the model instead of the raw content:
Error: result (1,055,387 characters) exceeds maximum allowed tokens.
Output has been saved to /Users/ben/.claude/projects/.../tool-results/...
Format: JSON array with schema: [{type: string, text: string}]
Use offset and limit parameters to read specific portions of the file,
the Grep tool to search for specific content, and jq to make structured queries.
This is much better than truncation because:
- Data isn't lost - the full output is preserved
- Model can explore - using Read (with offset/limit), Grep, or jq
- Context stays small - only the file path and instructions go into context
Would you like me to update the fix to implement this pattern instead of simple truncation? It would involve:
1. Writing large MCP outputs to .opencode/tool-results/ (or similar)
2. Returning a message with the file path and exploration instructions
3. The model can then use existing tools (Read, Grep, Bash with jq) to explore
Reacted by Justin Carlson, Alexei Nunez and Erik James Fritsch
I have the same problem with opencode , claude opus 4.5 and BMAD, I asked the agent to try to fix the probleme
Done! The session should now work.
Summary of the Root Cause & Fix
Root Cause: OpenCode stores ALL tool outputs (webfetch, read, write, task results) in the session history. When you fetch large web pages or read large files, they accumulate and
eventually exceed the 200K token limit.
What I Fixed:
- Truncated 20+ large parts in your session
- Reduced session from ~330KB to ~123KB
- Estimated tokens: from 200K+ down to ~47K
To Prevent This in Future:
1. Avoid using webfetch on large documentation pages
2. If you need to read large files, summarize them rather than keeping full content
3. Consider starting a new session when doing research-heavy work with lots of webfetches
4. OpenCode should ideally have auto-truncation, but until then, be mindful of large fetches
Try your session now! 🚀
I ended up creating #6234 for this since I had to patch this in my local fork I use, opencode was pretty unusable for me without it and I couldn't wait for a fix. Not sure if opencode team will accept it, but at least it is shared here so others can merge it onto their own versions if desired.
Still getting this issue using opus 4.6 on February 2026
Reacted by Alexander Grosse, Oscar Morante, Stanislas, Marcel Folaron, dida1990, Evandro Sasse, RiveraHan, Faris Alherf, Susanth Kakarla, Colin Willson and 20 more
Activity
arsham commentedon Dec 11, 2025
Was there a tool call just before that? If that was the case, the result of the tool call must have been large. Your only option is to run
/undoand then add an additional guidance to the agent to be more careful.berenddeboer commentedon Dec 11, 2025
Yeah, plenty of things going on.
rekram1-node commentedon Dec 11, 2025
I'm gonna make it more resilient to these things soon, @arsham nails it w/ suggestion but ofc this isn't really an "acceptable" ux for you guys and that's on us. Will be better soon!
taxilian commentedon Dec 15, 2025
I haven't seen this much lately, things have been fantastic... but today suddenly it's happened now three times in a row doing different tasks. Did anything change recently?
taxilian commentedon Dec 15, 2025
can't even undo and auto compact, it's failing on the compact message
rekram1-node commentedon Dec 15, 2025
@taxilian could u share:
opencode export > session.jsontaxilian commentedon Dec 15, 2025
It just happened again.
This is with claude opus 4.5, anthropic pro plan.
The other session is in a weird state now because it's the one I tried to fix. This is exactly the same thing I was working on Friday / Saturday though and haven't seen this issue before, now it keeps happening left and right.
taxilian commentedon Dec 15, 2025
session.json
session2.json
I think those are the same two
taxilian commentedon Dec 15, 2025
I am on the community discord server if that's useful. still trying to make this work
rekram1-node commentedon Dec 16, 2025
It looks like it's because of the "bd" cmd in bash it's absolutely devouring tokens
rekram1-node commentedon Dec 16, 2025
I think the proper pty should fix that
ben-vargas commentedon Dec 17, 2025
Yeah, I'm running into similar error a ton, haven't been able to reliably use opencode for a few versions now. This is on the latest v1.0.164 and there was a firecrawl scrape right before truncation failed to work?
Also opus 4.5 (max plan).
justcarlson commentedon Dec 19, 2025
session.json
Also running into this a lot.
It's definitely large tool calls that are devouring context.
Probably because of bd (but it's so good).
Model: Anthropic/Claude Opus 4.5
If I switch model to Gemini, it's fine (mostly).
Truncation isn't aggressive enough, I think.
Cleaned up JSON from my session showing where it all went wrong.
[ { info: { id: msg_b3475413b001geGkBJYoGtUd0o, role: assistant, modelID: claude-opus-4-5, tokens: { input: 6, output: 10586, cache: { read: 68795, write: 12195 } }, finish: tool-calls }, parts: [ { type: reasoning, text: Good, test file cleaned up. Now I need to push these commits to the PR and update the PR. }, { type: tool, tool: bash, state: { status: completed, input: { command: git push 2>&1, description: Push cleanup commits, env: { /* ... [21,965 character-indexed entries truncated] ... */ CI: true, DEBIAN_FRONTEND: noninteractive, GIT_TERMINAL_PROMPT: 0, GCM_INTERACTIVE: never, HOMEBREW_NO_AUTO_UPDATE: 1 } }, output: To https://github.com/justcarlson/dotfiles.git\n d263a20..f890276 feat/beads-init -> feat/beads-init\n, time: { start: 1766111786187, end: 1766111786842 } } } ] }, { info: { id: msg_b3477378e001PSDz7CbpYGme0T, role: assistant, error: { name: APIError, data: { message: prompt is too long: 212032 tokens > 200000 maximum, statusCode: 400, responseBody: {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 212032 tokens > 200000 maximum"},"request_id":"req_011CWFGUE8UeR24su49Cs3jB"} } } }, parts: [] } ] ...ben-vargas commentedon Dec 19, 2025
I didn't post it here, but I did in a thread on their discord... my root cause (at least for my issue) is non-truncated mcp tool calls dumping too much into the context window. There should be a truncation of mcp and all tools, similar to the 30k limit on bash/internal tools.
I created a personal fix, but haven't PR'd it because opencode maintainers should probably weigh in on how they want to address this (truncation vs something like claude does - detailed below).
https://discord.com/channels/1391832426048651334/1450309314337308762
Claude Code has a unique way of handling really large bash outputs that I noticed... I asked it to explain the approach:
justcarlson commentedon Dec 19, 2025
I am loving this idea
CybotTM commentedon Dec 19, 2025
Not sure if this #5360 or #1092 or #4845 are all about the same or more specific different issues, so I just post here: me too! ;-)
Run into this every time on /compact ... sadly, but this makes OpenCode currently unusable for me. :-(
guilllex commentedon Dec 24, 2025
I have the same problem with opencode , claude opus 4.5 and BMAD, I asked the agent to try to fix the probleme
Done! The session should now work.
ben-vargas commentedon Dec 27, 2025
I ended up creating #6234 for this since I had to patch this in my local fork I use, opencode was pretty unusable for me without it and I couldn't wait for a fix. Not sure if opencode team will accept it, but at least it is shared here so others can merge it onto their own versions if desired.
PeterHa-UoH commentedon Dec 30, 2025
does anyone find a way to fix this?
Traves-Theberge commentedon Dec 31, 2025
Same issue specifically when running up services for docker compose.. and using Claude code. it doesn't condense and summarize properly.
rekram1-node commentedon Dec 31, 2025
fixing soon
raadkasem commentedon Feb 6, 2026
Still getting this issue using opus 4.6 on February 2026
MalteBoehm commentedon Feb 15, 2026
me too