#8888: fix: increase tool result/error context limits
agents
stale
Cluster:
Context Management Enhancements
## Problem
Tool outputs are truncated before being passed back to the model:
- **Tool results:** 8000 chars (loses large diffs, test output)
- **Tool errors:** 400 chars (loses stack traces)
This causes batch processing failures where the model can't understand what went wrong or what the full output was.
## Solution
Increase limits to preserve more context:
- `TOOL_RESULT_MAX_CHARS`: 8000 → 16000
- `TOOL_ERROR_MAX_CHARS`: 400 → 2000
## Impact
- Better batch processing reliability
- Model can see full stack traces for debugging
- Large outputs (git diff, test results) are less likely to be truncated
## Testing
Manual testing with batch operations showed improved error recovery and context preservation.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR increases the maximum size of tool outputs passed back to the model in `src/agents/pi-embedded-subscribe.tools.ts`, raising tool result truncation from 8k→16k characters and tool error message truncation from 400→2000 characters. The change is implemented by updating the constants used by `truncateToolText` (for `content[].text`) and `normalizeToolErrorText`/`extractToolErrorMessage` (for error summaries), with added inline documentation explaining the intent (preserve more diff/test output and stack trace context).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is confined to two constants that control truncation length for tool result text and single-line error summaries; the logic paths and function behavior remain unchanged aside from allowing more context through.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#5057: fix: add per-tool-result hard cap to prevent context overflow
by hanxiao · 2026-01-31
84.3%
#23803: Fix tool metadata truncation
by kamal-ayman · 2026-02-22
82.1%
#9861: fix(agents): re-run tool_use/tool_result repair after limitHistoryT...
by CyberSinister · 2026-02-05
81.0%
#8890: fix: increase bash output chunk limit from 8KB to 32KB
by joetomasone · 2026-02-04
80.0%
#2557: fix(agents): preserve tool call/result pairing in history limiting
by steve-rodri · 2026-01-27
79.3%
#11825: fix: keep tool_use/tool_result pairs together during session compac...
by C31gordon · 2026-02-08
78.4%
#16261: feat(agents): add two-tier tool output truncation and excludeFromCo...
by ProgramCaiCai · 2026-02-14
78.4%
#6819: fix(tui): handle unstructured tool results and errors in tool execu...
by TreyDong · 2026-02-02
78.3%
#3872: improve bash-tools.exec.ts code quality
by Bestom927 · 2026-01-29
78.3%
#21195: fix: suppress orphaned tool_use/tool_result errors after session co...
by ruslansychov-git · 2026-02-19
77.9%