GeezerVison is showing github.com — [Question] Is automatic tool calling output truncation supported? · Issue #4826 · anomalyco/opencode
[Question] Is automatic tool calling output truncation supported? #4826DescriptionQuestion
I am trying out Opencode as a potential replacement for Codex. One thing I have noticed, that sometimes the model attempts to read a huge file or runs a "glob" tool call with wildcards which result in results north of 100k tokens in a single tool call output. This negatively impacts the performance of the model, as well as cause cost issues.
Is there some configuration that I can use to automatically truncate the output of tool calls, and let the model know it's been truncated so it can adjust its tool calls to find the relevant information? It's the one thing that Codex seems to do a lot better, but other than that I am really liking opencode so far.
Thanks! Activitygithub-actions commented on Nov 27, 2025 This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if your specific case about automatic tool output truncation differs from these context management discussions. Mushoz commented on Nov 27, 2025 This one is a little bit extreme, but maybe it explains the issue I am having:
{"error":{"code":400,"message":"the request exceeds the available context size, try increasing it","type":"exceed_context_size_error","n_prompt_tokens":1463244,"n_ctx":262144}}
It was caused by the model trying to grep something with way too many results nikhilmaddirala commented on Nov 27, 2025 Claude Code handles this quite well by delegating such tasks to the "explore" subagent so the tool calls don't pollute the main agent's context window. I wonder if you try defining such an agent for yourself. Or even just instructing the model to use Opencode's "general" subagent to delegate such tasks. rekram1-node commented on Nov 27, 2025 we can be fancier here but rn we do automatically prune sufficiently old tool calls from context to free up space Mushoz commented on Dec 9, 2025
Claude Code handles this quite well by delegating such tasks to the "explore" subagent so the tool calls don't pollute the main agent's context window.
That wouldn't fix this particular case though. This single tool call returned over a million token. A subagent would fail to run with such a big tool call result as well. Sure, it won't pollute the main agent's context window, but it's not retrieving the right answer either.
we can be fancier here but rn we do automatically prune sufficiently old tool calls from context to free up space
This is only helpful if the tool call itself did not result in the context window overflowing. And even if it didn't, it's still a lot of trash in the context. Would it be a bit think to just truncate the output after 500 lines or so (maybe make it configurable). And if it is truncated, let the model know with some text like "Truncated, only showing first 500 lines out of 21416". erikdemarco commented on Oct 21, 2026 @Mushoz sorry just curious. You still use reranker? You used to defend reranker model so much.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|