Repository navigation
Description
Problem
There is no global ceiling on how large a tool result can be. Only two tools truncate at all:
source/tools/execute-bash.tsx:50-54(head-only, 2000 chars)source/custom-tools/handler.ts:100-101(head-only, same constant)
Everything else is unbounded, including:
read_filewith an explicit range covering a huge filestring_replaceandwrite_file, which return the whole post-edit filegit_diff(source/tools/git/git-diff.tsx:71), which returns full diff content plus a[Total: N lines]footerlist_directoryrecursive listings- MCP tool results, which we do not control at all
A single large diff or a recursive listing of a big tree can dominate the context window, and because tool results persist in the conversation, the cost is re-sent on every subsequent step.
Proposal
Add one choke point that caps any tool result before it enters the conversation, with head-plus-tail elision and a clear marker telling the model what was dropped and how to get it.
Making it structural rather than per-tool means unbounded output becomes impossible by construction, and it covers MCP and custom tools that we do not own.
Design questions worth settling on the issue:
- Where the choke point lives.
ToolManageris the natural place since it already wraps every tool including MCP and custom ones. - Whether the cap should be a fixed character count or a share of the model's context window. The latter is better but needs the context size plumbed through.
- Whether some tools should be exempt or get a higher ceiling.
- Whether the elided content should be recoverable, for example written to a temp file the model can read a range from.
Related
Several individual uncapped tools have their own issues. This one is the structural fix that would make those individually less critical, but it is more invasive, so the per-tool fixes are probably worth landing first.
Activity
will-lamerton commentedon Aug 3, 2026
Part of #772.
RealBhupesh commentedon Aug 4, 2026
I'd like to take this issue.
Plan:
I'll keep structured tool payloads intact and cap only the LLM-facing text content.
RealBhupesh commentedon Aug 4, 2026
Implemented and submitted as ready-for-review PR #786: #786
What changed:
Validation:
source/app/components/settings-tabs.spec.tsx:109because the baseline test expects theDisplaytab.The PR is open and ready for maintainer review; GitHub Actions checks are currently queued.