#17024: fix(tool errors): suppress compaction-related tool errors
agents
stale
size: XS
Cluster:
Error Handling in Agent Tools
Fixes #16948
## Problem
When session is compacted during long-running tool calls, the tool result tries to deliver to a context where the original tool_call ID no longer exists. The error message leaks to user chat.
## Solution
Add compaction-related error keywords to RECOVERABLE_TOOL_ERROR_KEYWORDS:
- "no tool call found"
- "tool call.*not found"
- "call_id.*not found"
These errors are not user-actionable (the tool call was already dropped during compaction), so they should be suppressed from the chat surface.
## Impact
- Users no longer see confusing error messages about missing tool calls
- Tool errors that cannot be recovered are silently suppressed instead of leaking
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added three new keywords to suppress compaction-related tool errors that occur when a tool result tries to deliver to a context where the original tool call ID no longer exists after session compaction.
**Critical issue found:**
- The regex patterns `"tool call.*not found"` and `"call_id.*not found"` won't work as intended because `isRecoverableToolError` uses `.includes()` for literal string matching, not regex matching. The `.*` will be treated as literal characters, preventing these patterns from matching actual error messages.
<h3>Confidence Score: 1/5</h3>
- This PR has a critical bug that prevents the fix from working as intended
- The implementation uses regex-style patterns with `.includes()` which performs literal string matching, not regex matching. The patterns `"tool call.*not found"` and `"call_id.*not found"` will never match actual error messages because the `.*` characters are treated literally. This means the intended fix will not suppress the compaction-related errors it was designed to suppress. The first pattern `"no tool call found"` will work, but the other two will not.
- src/agents/pi-embedded-runner/run/payloads.ts requires correction before merge
<sub>Last reviewed commit: e2dbdd5</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#21195: fix: suppress orphaned tool_use/tool_result errors after session co...
by ruslansychov-git · 2026-02-19
80.9%
#18466: fix: suppress recoverable mutating tool errors when agent already r...
by stijnhoste · 2026-02-16
80.9%
#16095: fix: remove orphaned tool_result blocks during compaction (#15691)
by claw-sylphx · 2026-02-14
79.8%
#13282: fix(agents): instruct agent not to retry lost tool results
by thebtf · 2026-02-10
79.5%
#21201: fix(compaction): repair tool_use/tool_result pairing after compaction
by ruslansychov-git · 2026-02-19
79.1%
#13062: fix: remove orphaned tool_result blocks from user message content d...
by trevorgordon981 · 2026-02-10
79.0%
#12487: fix(agents): strip orphaned tool_result when tool_use is sanitized ...
by skylarkoo7 · 2026-02-09
78.8%
#20538: fix: handle orphaned tool_result errors gracefully instead of leaki...
by echoVic · 2026-02-19
78.6%
#4852: fix(agents): sanitize tool pairing after compaction and history tru...
by lailoo · 2026-01-30
77.3%
#4844: fix(agents): skip error/aborted assistant messages in transcript re...
by lailoo · 2026-01-30
77.1%