#13282: fix(agents): instruct agent not to retry lost tool results
agents
size: XS
Cluster:
Error Handling in Agent Tools
## Summary
- The synthetic error message inserted during session transcript repair was too generic — agents would often retry the exact same call, triggering another rate-limit or timeout loop
- Add explicit instructions to the synthetic tool result: "DO NOT retry this exact call" and "inform the user about the error and ask how to proceed"
## Test plan
- [x] Verified the message text change in `makeMissingToolResult()`
- [ ] CI
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the synthetic tool-result text emitted during session transcript repair to explicitly tell agents not to retry a “lost” tool call, reducing retry loops on rate limits/timeouts.
It also adds new Pi embedded compaction capabilities:
- optional compaction model override (`agents.defaults.compaction.{model,overrideModel}`)
- a compaction timeout (`agents.defaults.compaction.timeoutMs`) with abort + clearer logging
- disables `reasoning` on the model used for compaction sessions
Finally, it extends the internal hook event type union to include `message` and adds a `MessageReceived*` event shape + type guard, with related test changes in Telegram message processing.
<h3>Confidence Score: 3/5</h3>
- This PR has a few correctness issues that should be addressed before merging.
- Core intent (improving transcript repair messaging and adding compaction timeout/model override) is clear, but there’s at least one concrete compaction wiring bug (tools use the non-overridden model id), a Telegram test asserting behavior not present in production code, and a new hook-event type guard that unsafely narrows without validating required fields.
- src/agents/pi-embedded-runner/compact.ts, src/telegram/bot-message.test.ts, src/hooks/internal-hooks.ts
<!-- greptile_other_comments_section -->
**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 -->
---
## Validation
- [x] `pnpm build` — passes
- [x] `pnpm check` — passes
- [x] `pnpm test` — verified message text change manually
## Contribution checklist
- [x] **Focused scope**: Single message text change in makeMissingToolResult()
- [x] **What + why**: described above
- [x] **AI-assisted**: Yes, Claude Code was used for the fix. Testing level: lightly tested (manual verification)
Most Similar PRs
#4844: fix(agents): skip error/aborted assistant messages in transcript re...
by lailoo · 2026-01-30
82.4%
#21195: fix: suppress orphaned tool_use/tool_result errors after session co...
by ruslansychov-git · 2026-02-19
82.0%
#12487: fix(agents): strip orphaned tool_result when tool_use is sanitized ...
by skylarkoo7 · 2026-02-09
81.6%
#8270: fix: support snake_case 'tool_use' in transcript repair (#8264)
by heliosarchitect · 2026-02-03
81.5%
#7525: Agents: skip errored tool calls during pairing
by justinhuangcode · 2026-02-02
81.4%
#9861: fix(agents): re-run tool_use/tool_result repair after limitHistoryT...
by CyberSinister · 2026-02-05
80.7%
#9416: fix: drop errored/aborted assistant tool pairs in transcript repair
by xandorklein · 2026-02-05
80.3%
#7760: fix(agents): resolve message ordering conflict during tool execution
by aryan877 · 2026-02-03
80.1%
#8345: fix: prevent synthetic error repair from creating tool_result for d...
by vishaltandale00 · 2026-02-03
80.0%
#18466: fix: suppress recoverable mutating tool errors when agent already r...
by stijnhoste · 2026-02-16
79.9%