Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 12:26 PM ET / 16:26 UTC. Summary PR surface: Source +9, Tests +26. Total +35 across 2 files. Reproducibility: yes. The PR provides a real production-handler wall-clock reproduction with a real Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the shared abort-aware retry wait after the behind-base merge result and exact-head checks are confirmed, retaining both the abort regression and existing non-abort retry coverage. Do we have a high-confidence way to reproduce the issue? Yes. The PR provides a real production-handler wall-clock reproduction with a real Is this the best way to solve the issue? Yes. Sharing the established abort-aware sleep and lifecycle mapping across both retry branches is narrower and more maintainable than adding another bespoke timer or cancellation path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7128f6ddbb20. Label changesLabel justifications:
Evidence reviewedPR surface: Source +9, Tests +26. Total +35 across 2 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
Review history (2 earlier review cycles)
|
c4a35d2 to
5406b75
Compare
|
Rebased onto current main (5406b75099). The two failing checks were unrelated to this diff (
Focused proof after rebase: |
The transient-HTTP retry in handleAgentExecutionError slept its full
TRANSIENT_HTTP_RETRY_DELAY_MS (2500ms) on a bare setTimeout, ignoring the
turn abortSignal. A cancelled turn stayed parked for the whole backoff and
then returned { kind: "retry" }, issuing another provider attempt after
cancellation.
Mirror the sibling overload-retry branch (abort-aware since openclaw#109354):
sleep via sleepWithAbort with turn.replyOperation?.abortSignal ??
turn.opts?.abortSignal and map a sleep rejection through
resolveReplyOperationAbortAction, returning the abort action when set.
Co-Authored-By: Claude <[email protected]>
5406b75 to
872b25a
Compare
|
Maintainer review complete. This is the best fix for the retry-lifecycle boundary: transient HTTP backoff now shares the existing abort-aware wait and reply-operation abort mapping, and cancellation clears the pending timer without a second provider call. Proof:
Ready for maintainer prepare/merge. |
|
Merged via squash.
|
…penclaw#109805) * fix(auto-reply): honor abortSignal in transient-HTTP retry backoff The transient-HTTP retry in handleAgentExecutionError slept its full TRANSIENT_HTTP_RETRY_DELAY_MS (2500ms) on a bare setTimeout, ignoring the turn abortSignal. A cancelled turn stayed parked for the whole backoff and then returned { kind: "retry" }, issuing another provider attempt after cancellation. Mirror the sibling overload-retry branch (abort-aware since openclaw#109354): sleep via sleepWithAbort with turn.replyOperation?.abortSignal ?? turn.opts?.abortSignal and map a sleep rejection through resolveReplyOperationAbortAction, returning the abort action when set. Co-Authored-By: Claude <[email protected]> * refactor(auto-reply): share abortable retry backoff * fix(auto-reply): make retry wait fallthrough explicit --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Add optional signal parameter so callers can cancel the drain wait instead of blocking until the deadline expires. On abort the function returns the current drain state near-instantly — matching the pattern from openclaw#109805 and openclaw#109913.
What Problem This Solves
The transient-HTTP retry in
handleAgentExecutionError(src/auto-reply/reply/agent-runner-error-handler.ts:405-414) waits out its backoff on a baresetTimeout(resolve, TRANSIENT_HTTP_RETRY_DELAY_MS)— 2 500 ms (TRANSIENT_HTTP_RETRY_DELAY_MS = 2_500, line 60) — that never receives the turn'sAbortSignal. When a reply turn is cancelled mid-backoff (user stop, session abort, gateway/channel teardown), the error handler stays parked for the full 2 500 ms, and — worse — it then returns{ kind: "retry" }, so the turn loop issues another provider attempt for a turn whose result will be discarded. Turn teardown is delayed for every auto-reply channel (telegram included) each time a transient HTTP provider error (5xx/timeout) races with a cancellation.Sibling parity: the overload-retry branch ~30 lines above in the same function was made abort-aware by #109354 (merged 2026-07-16) — it computes
retryAbortSignal = turn.replyOperation?.abortSignal ?? turn.opts?.abortSignal(line 275) and sleeps viasleepWithAbort(retryDelayMs, retryAbortSignal)inside atry/catchthat maps the rejection throughresolveReplyOperationAbortAction(lines 383-391). The transient-HTTP backoff was simply left behind.Why This Change Was Made
Mirror the overload branch exactly.
sleepWithAbort(src/infra/backoff.ts, re-exported frompackages/retry/src/index.ts:21) andresolveReplyOperationAbortAction(line 130) are already imported/in scope in this file, and the sameturn.replyOperation?.abortSignal ?? turn.opts?.abortSignalexpression is what the caller already uses forrunAbortSignal(agent-runner-execution.ts:260) and what the overload branch uses for its own retry sleep.await new Promise<void>((resolve) => { setTimeout(resolve, TRANSIENT_HTTP_RETRY_DELAY_MS); }); return { kind: "retry" };retryAbortSignal(same expression as the overload branch),await sleepWithAbort(TRANSIENT_HTTP_RETRY_DELAY_MS, retryAbortSignal)inside the sametry/catch→resolveReplyOperationAbortAction(sleepError)pattern (return the abort action when set, otherwise rethrow), thenreturn { kind: "retry" }unchanged when not aborted.No new config, no new constants, no new helpers, no behavior change when the signal is not aborted: the delay value, the single-retry budget, and the log line are untouched. Non-test LOC:
+10 / -3on one file.This follows the same bare-
setTimeout→sleepWithAbortpattern as merged #108561 (discord gateway READY backoff) and #109604 (telegram startup probe retry).User Impact
Cancelling a reply turn (stop command, session reset, gateway shutdown, channel teardown) while a transient HTTP provider error retry is parked now unwinds the turn immediately with the abort lifecycle action (
NO_REPLYfor a user abort, restart copy for a restart abort) instead of waiting out the remaining backoff and firing one more doomed provider request.Evidence
Real behavior proof — production handler, real
AbortController, wall-clockUncommitted
scratchpad/proof-transient-retry-abort.mts(not in this PR) calls the real exportedhandleAgentExecutionErrorwith a transient-HTTP-shaped provider error (521 <!DOCTYPE html>…Cloudflare…),consumeTransientHttpRetry: () => true, a realAbortControllerwired asturn.replyOperation.abortSignal, and real wall-clock timers (novi.mock, no fake timers). It lets the handler park in the backoff, firesabort()at ~100 ms, and measures abort-to-return.Before (main @
e01027dd28, baresetTimeout):Abort fired ~100 ms in; the handler still sat the full 2 500 ms backoff and then returned
retry— i.e. the turn loop would run the provider again after cancellation.After (this PR):
Same script, same timing: the abort interrupts the backoff in ~1 ms and the handler returns the user-abort lifecycle action.
Run with:
node --import tsx scratchpad/proof-transient-retry-abort.mts(Node v24.15.0, Linux x86_64).Regression coverage
interrupts the transient HTTP retry backoff on abortinsrc/auto-reply/reply/agent-runner-execution-provider-failures.test.ts— drivesrunAgentTurnWithFallbackwith a transient failover error (FailoverErrorreasontimeout, the sameisTransientHttpbranch; this test harness stubs message-basedisTransientHttpErrortofalse), aborts mid-backoff, and asserts the turn resolves to the user-abort final payload with no second provider attempt (runEmbeddedAgentMockcalled once).retries once after transient 521 HTML failure and then succeedsinagent-runner.misc.runreplyagent.test.tslocks the non-abort behavior (waits the 2 500 ms, retries once, succeeds) — unchanged.Control-red verification
Reverting only the source hunk (keeping the new test) makes the new test hang indefinitely — the bare
setTimeoutparks the handler for the full backoff and nothing observes the abort; Vitest reported no output for 120 s and was terminated. Restoring the fix: pass. The wall-clock proof above shows the same contrast on the real handler (2 402 ms → 1.1 ms).Tests & checks
node scripts/run-vitest.mjs run src/auto-reply/reply/agent-runner-execution-provider-failures.test.ts— 66/66 passednode scripts/run-vitest.mjs run src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts— 75/75 passednode scripts/run-oxlint.mjs <both files>— exit 0node scripts/run-tsgo.mjs -p tsconfig.core.json— exit 0node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json— exit 0git diff --check— cleanOut of scope
The overload-retry branch (already abort-aware since #109354), the overload notice delivery timeout, and
TRANSIENT_HTTP_RETRY_DELAY_MS's value/retry budget are unchanged. Other bare sleeps elsewhere in the auto-reply runner were not touched.Risk
resolveReplyOperationAbortActionfall-through), preserving existing semantics.AI-assisted; reviewed before submission.