Chat loops forever when a compacted tool result is evicted: the retrieve miss tells the model to re-run
Summary
Chat can hang forever and never answer: the model retrieves a compacted tool result, the store misses, and the miss message tells it to re-run the tool — which reproduces the same oversized result, which is compacted and offloaded again.
Problem
A large tool result is compacted to a summary plus a retrieve_tool_output(hash) / ⟦tj:hash⟧ marker, with the original offloaded to the CCR store. When the model later retrieves that hash and the entry is gone, the error instructs it to "re-run the tool to regenerate it". Re-running produces the same oversized output, which is compacted and offloaded under a new hash that misses just as fast. Observed live: a parent agent re-delegated to a subagent forever on an evicted result, burning turns and cost with no reply.
The eviction itself is easy to hit. The in-memory CCR store is FIFO-bounded at 256 entries and lost on restart, so a retrieve footer the model was handed can go stale inside a single busy turn.
Steps to reproduce:
- Run a turn whose tool result is large enough to be compacted and offloaded.
- Keep the turn busy until the entry is evicted (or restart the core).
- Have the model retrieve the hash from its footer.
Expected: the model proceeds with the summary it already has. Actual: it re-runs the same call and the cycle repeats without bound.
Solution (optional)
Two changes: make the retrieve-miss message state that the original is gone, that the same call must not be re-run, and that the compacted summary is what to proceed with (narrower arguments only if a specific detail is essential); and default ccr_disk_enabled ON so the TTL/size-capped disk tier keeps offloaded originals recoverable, making a compaction footer a promise the store can keep. Configs that explicitly set false stay unchanged.
Acceptance criteria
- [ ] Repro gone — an evicted retrieve ends the turn with a slightly less detailed answer, not an unbounded loop.
- [ ] Both retrieve surfaces covered —
retrieve_tool_outputandtokenjuice_retrieve. - [ ] Opt-out preserved — an explicit
ccr_disk_enabled = falseis honoured. - [ ] Regression safety — coverage asserting the miss message does not instruct a blind re-run.
- [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate.
Related
Fix: #5257