-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
Description
Hi, when using OpenCode for non-coding task I encountered truncation problems. Investigating complains from my agent led me to discovering multiple problems around truncation in OpenCode.
First, truncation is not documented. As far as I can tell it is not mentioned in the docs at all.
Second, it is not configurable. MAX_LINES/BYTES are hardcoded and cannot be changed.
Third, model receives misleading instructions.
opencode/packages/opencode/src/tool/truncation.ts
Lines 96 to 98 in 9b23130
| const hint = hasTaskTool(agent) | |
| ? `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse the Task tool to have explore agent process this file with Grep and Read (with offset/limit). Do NOT read the full file yourself - delegate to save context.` | |
| : `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse Grep to search the full content or Read with offset/limit to view specific sections.` |
Message received by model is conditional based on the presence of task tool but not agents or other tools. "Use the Task tool to have explore agent..." is an incorrect instruction if explore agent is disabled. "Use Grep to search the full content or Read with offset/limit to view specific sections." is an incorrect instruction if Grep/Read tools are disabled. In scenario when those tools are not available it is completely impossible for the agent to access the full response in any way.
Fourth, inconsistent execution order of truncation and tool.execute.after hook. I tried to use the hook to reverse the truncation but for MCP calls it is called before truncation. I've not tested it but as far as I understand the code for all other tools (built-in and from plugins) it is called after truncation. This should be consistent.
Thanks
Plugins
No response
OpenCode version
1.2.5
Steps to reproduce
- Add MCP that returns response beyond truncation.
- Disable all tools besides the mentioned MCP server.
- Observe confused agent struggling with truncated output.
Screenshot and/or share link
I think the description is clear enough. I guess I can prepare dedicated example but it should not be necessary.
Operating System
Windows WSL
Terminal
Windows Terminal