Repository navigation
fix: replies show "Reply operation stalled" and rerun when provider rate limits outlast the watchdog - #183545
Conversation
…koff When provider 429s outlast the reply watchdog's six-minute progress horizon, the watchdog stopped the turn mid-backoff and reported it as "Reply operation stalled". Stalled-turn recovery then immediately reran the request into the same saturated quota, where it stalled again. The rate-limit retry wait now carries its completed retry count to the session watchdog. A watchdog stop that finds an open rate-limit backoff reports rate-limit copy, marks the operation `rate_limited`, skips the stalled-turn recovery rerun, and sends a rate-limit last-resort notice instead of the "stopped making progress" notice. Watchdog timing and abort handling are unchanged; other stalls behave as before. Release note: turns stopped by sustained provider rate limits now say so instead of "Reply operation stalled", and are no longer automatically rerun into the same rate limit.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesDistinguish watchdog stops during provider rate-limit backoff from ordinary stalls, show rate-limit feedback, and skip automatic stall recovery. Example: An isolated Gateway receives sustained HTTP 429 responses until its six-minute watchdog stops the turn after 11 retries.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR addresses a real rate-limit recovery failure, but its new watchdog dependency creates an import cycle that blocks CI. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe embedded runner records bounded retry waits on the session watchdog; reply dispatch and follow-up delivery consume the watchdog’s terminal classification to choose feedback and recovery. flowchart TD
A[Provider HTTP 429] --> B[Failover retry controller]
B --> C[Deferred lifecycle owner]
C --> D[Session watchdog]
D --> E[Operation stop classification]
E --> F[Reply feedback]
E --> G[Recovery queue decision]
Technical reviewBest possible solution: Keep the existing watchdog classification and recovery changes while extracting the shared rate-limit formatting into a dependency-free leaf consumed by both owners. Do we have a high-confidence way to reproduce the issue? Current-main source shows generic stall classification followed by automatic continuation, and the PR supplies a matching Gateway reproduction with sustained HTTP 429 responses. Is this the best way to solve the issue? The behavioral fix uses the existing retry and watchdog owners appropriately; the shared formatter needs a leaf dependency to preserve the repository’s acyclic static import contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ca976fb8899. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +55, Tests +58. Total +113 across 16 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 7:34 AM ET / 11:34 UTC. |
…pens Importing the failover user copy into the session watchdog pulled `session-controller.watchdog.ts` into a large static import cycle (madge `check-guards-architecture`). The retry controller, which already owns the rate-limit exhaustion copy, now renders the stop message and hands it to the watchdog on the retry wait it opens. The watchdog only uses the open wait's explanation, so `src/sessions` no longer imports failover copy. Behavior is unchanged.
…og-notice # Conflicts: # src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts
|
Merged via squash auto-merge.
|
…ate limits outlast the watchdog (openclaw#183545) * fix(sessions): report rate limits when the watchdog stops a retry backoff When provider 429s outlast the reply watchdog's six-minute progress horizon, the watchdog stopped the turn mid-backoff and reported it as "Reply operation stalled". Stalled-turn recovery then immediately reran the request into the same saturated quota, where it stalled again. The rate-limit retry wait now carries its completed retry count to the session watchdog. A watchdog stop that finds an open rate-limit backoff reports rate-limit copy, marks the operation `rate_limited`, skips the stalled-turn recovery rerun, and sends a rate-limit last-resort notice instead of the "stopped making progress" notice. Watchdog timing and abort handling are unchanged; other stalls behave as before. Release note: turns stopped by sustained provider rate limits now say so instead of "Reply operation stalled", and are no longer automatically rerun into the same rate limit. * fix(sessions): render the rate-limit stop copy where the retry wait opens Importing the failover user copy into the session watchdog pulled `session-controller.watchdog.ts` into a large static import cycle (madge `check-guards-architecture`). The retry controller, which already owns the rate-limit exhaustion copy, now renders the stop message and hands it to the watchdog on the retry wait it opens. The watchdog only uses the open wait's explanation, so `src/sessions` no longer imports failover copy. Behavior is unchanged.
What Problem This Solves
Fixes: a reply shows "Reply operation stalled" and is automatically rerun when provider rate limits (sustained HTTP 429s) outlast the session watchdog.
User Impact
User impact: when a turn is stopped because the model provider keeps rate-limiting it, people now see "Rate-limit recovery stopped after N automatic retries without a completed model response. Check completed work before trying again." instead of "Reply operation stalled". The turn is no longer automatically rerun into the same rate limit, which previously repeated the six-minute wait and added more 429 pressure. Channel users get a rate-limit notice instead of "This turn was interrupted because it stopped making progress". Stalls that are not rate limits behave exactly as before.
Why This Change Was Made
The rate-limit retry loop allows 15 retries with backoff up to 60 s, which is longer than the watchdog's six-minute window without progress. Retry waits are intentionally capped at that window. So under sustained 429s, the watchdog always stopped the turn in the middle of a backoff, labeled it a stall, and stalled-turn recovery immediately queued a rerun that hit the same limit.
The retry wait now tells the watchdog how many rate-limit retries have completed. When the watchdog stops a turn while that backoff is open, it reports rate-limit copy and marks the stop
rate_limited. Stalled-turn recovery skipsrate_limitedstops, and the last-resort notice uses rate-limit text. Watchdog timing, retry allowances, and abort handling are unchanged: the abort is still anAbortErrorwith codeOPENCLAW_SESSION_WATCHDOG, and only its message differs.Accepted edge: if a retry request is in flight at the exact moment of the stop, no backoff is open and the stop still reports as a stall. That case is rare and still visible to the user.
Shape of the change
failover-retry-controller.tsrendersrenderRateLimitRecoveryStopped(retryCount)→onRetryWait(..., { rateLimitStopMessage })→ deferred lifecycle owner →beginDiagnosticRetryWait→ watchdogbeginWait({ kind: "retry", rateLimitStopMessage }).describeStop()returns the stale reason and abort error from the open retry wait;abortForStallreads it before aborting (the abort closes the wait).continueStalledReplyTurnreturns early forrate_limited;resolveStalledTurnNoticeTextpicks the notice at the three last-resort notice sites.renderRateLimitRecoveryStoppedkeeps the existing exhaustion copy, and for zero completed retries uses wording that does not claim recovery is disabled.Evidence
End to end, real product path. An isolated Gateway (own state dir and port) with one custom
openai-responsesprovider pointed at a local server that answers every request with an OpenAI-shaped TPM 429 (rate_limit_exceeded,type: tokens,retry-after-ms: 826). One Control UI-stylechat.sendturn:chat.historyafterwards contains only the user message andrun-failed-before-reply: "Your request couldn't be completed: Rate-limit recovery stopped after 11 automatic retries without a completed model response. …". There was no second main-session run and no stalled-turn recovery in the two minutes after the stop. The one later provider request came from the post-turn background skill-workshop review lane, not the turn. On the parent commit, the same stop is reported as "Reply operation stalled" and queues a recovery run. The regression tests below pin that, and it matches the incident that prompted this fix.The same rig, with fresh state, was rerun on each later revision:
765d3274, and the final head81e80a9e. Each time the result was identical. On81e80a9e:The transcript held only the user message and that notice, and the whole Gateway log showed exactly one main-session run ID. Of the 13 provider requests, 12 were the turn (1 initial plus 11 retries) and 1 was the background skill-workshop lane.
The second commit fixes a static import cycle that CI's
check-guards-architectureflagged on the first revision (watchdog → failover user copy). The retry controller now renders the stop copy and hands it to the watchdog on the retry wait, sosrc/sessionsno longer imports failover copy. Locally,check:madge-import-cyclesandcheck:import-cyclesboth report 0 cycles.Regression tests, red on the parent commit and green with the fix:
src/logging/diagnostic-controller-recovery.integration.test.ts: a real controller watchdog stop with a rate-limit retry wait open. On the parent:expected 'no_activity' to be 'rate_limited'.src/auto-reply/reply/agent-runner.stalled-turn.test.ts: arate_limitedstall queues no recovery run, does not claim or annotate a queued same-sender request, and selects the rate-limit notice. On the parent:continueStalledTurnreturnedtrue.Other checks:
failover-retry-controller.test.tspins the copy each rate-limit backoff hands the watchdog, including the zero-retry wording.tsgo:coreandtsgo:core:testpass, format and line-cap ratchet pass,git diff --checkis clean.81e80a9e, including earlier passes with the stop-path owners attached as context.Known unrelated local check failures on
main:check:deprecated-api-usageflagsscripts/perf/session-cost-refresh-measure.ts:55(from perf(usage): reduce duplicate bookkeeping during session backfill #183186).