fix(agents): retry compaction on provider-side AbortErrors#97504
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 10:58 AM ET / 14:58 UTC. Summary PR surface: Source +32, Tests +197. Total +229 across 5 files. Reproducibility: yes. at source level: current main routes AbortError-shaped compaction errors through terminal abort/timeout branches before checking whether the caller signal was aborted. I did not execute tests in this read-only review. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused bug fix after maintainer acceptance of the bounded compaction retry/fallback semantics and exact-head checks; keep broader fallback/abort consolidation separate. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main routes AbortError-shaped compaction errors through terminal abort/timeout branches before checking whether the caller signal was aborted. I did not execute tests in this read-only review. Is this the best way to solve the issue? Yes, this is the best narrow fix I found: it uses the existing AbortSignal already threaded through compaction, matches the merged model-fallback pattern, and adds no config or API surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9241b9701d9c. Label changesLabel justifications:
Evidence reviewedPR surface: Source +32, Tests +197. Total +229 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal.
2a305bc to
509a193
Compare
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]>
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]> (cherry picked from commit 245c18d)
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]>
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]>
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]> (cherry picked from commit 245c18d)
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]>
…97504) Align inner compaction retry and compaction-safeguard provider fallback with the openclaw#90908 signal.aborted pattern so undici disconnect AbortErrors retry or fall back to LLM instead of producing degraded placeholder summaries. Caller abort remains terminal. Co-authored-by: NIO <[email protected]> (cherry picked from commit 245c18d)
What Problem This Solves
Fixes an issue where long-running agent sessions would silently lose conversation context during compaction when the LLM API closed a connection mid-stream without the user cancelling the run.
PR #90908 fixed this classification for the outer
model-fallbacklayer, but the inner compaction retry path still treated provider-sideAbortErrors (for example undici's"This operation was aborted") as terminal user cancellations. That suppressed retries insummarizeChunksand skipped the LLM fallback incompaction-safeguardwhen a configured compaction provider disconnected the same way.The user-visible symptom: compaction appeared to succeed (
compacted: true) but the stored summary was a degraded placeholder such as"Summary unavailable due to size limits", erasing useful history without an obvious error.Why This Change Was Made
The fix aligns inner compaction error handling with the #90908 pattern: only treat an error as a caller-initiated cancellation when
AbortSignal.abortedis true. Provider-sideAbortErrors with an unaborted signal are retried (LLM path) or fall back to built-in LLM summarization (provider path). Real non-abort transport timeouts such as"fetch failed"/ETIMEDOUTkeep the existing no-retry behavior.summarizeWithFallbacknow rethrows on caller abort instead of swallowing the error into the placeholder fallback path.User Impact
signal.aborted) still stops immediately with no retry.Evidence
Behavior or issue addressed: Provider-side
AbortErrorduring compaction no longer suppresses retries or LLM fallback when the caller has not cancelled.Real environment tested: macOS, Node 22, local OpenClaw source checkout on branch
fix/compaction-provider-abort-retry, production modulessrc/agents/compaction.tsandsrc/agents/agent-hooks/compaction-safeguard.ts.Exact steps or command run after this patch:
pnpm build pnpm test src/agents/compaction.summarize-fallback.test.ts src/agents/agent-hooks/compaction-safeguard.test.ts src/agents/compaction.retry.test.ts node scripts/proof-compaction-provider-abort-retry.mjsEvidence after fix:
Proof script exercises the real production call chains:
summarizeWithFallback→summarizeChunks→retryAsync(compaction.ts)session_before_compact→tryProviderSummarize→ LLM fallback viasummarizeInStages(compaction-safeguard.ts)Regression tests mock only the external LLM API boundary (
generateSummary/ providersummarize); all classification and retry/fallback orchestration runs through production code.Observed result after fix: Provider-side
AbortErrorwith unaborted signal triggers a secondgenerateSummarycall and returns"recovered summary after provider disconnect"; safeguard provider failure invokessummarizeInStagesinstead of{ cancel: true }. Caller-aborted signal still throws immediately with a single attempt.What was not tested: Live gateway compaction against a real provider that disconnects mid-stream; Crabbox
pnpm check:changed(local Crabbox unavailable).Proof limitations or environment constraints: Proof uses production compaction modules with mocked LLM/provider network boundaries. No live network disconnect was injected during proof.
Tests and validation
pnpm build— passpnpm test src/agents/compaction.summarize-fallback.test.ts src/agents/agent-hooks/compaction-safeguard.test.ts src/agents/compaction.retry.test.ts— 106 passednode scripts/run-oxlint.mjs --tsconfig tsconfig.json src/agents/compaction.ts src/agents/agent-hooks/compaction-safeguard.ts— passsrc/agents/compaction.summarize-fallback.test.tsandsrc/agents/agent-hooks/compaction-safeguard.test.tsRisk checklist
Current review state
Related: #90908 (outer model-fallback fix; this PR completes the inner compaction layers)
AI-assisted.