Repository navigation
fix: recover from temporary provider overloads - #109354
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 517383487c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| params.state.pendingLifecycleTerminal = undefined; | ||
| turn.replyOperation?.recordActivity(); | ||
| return { kind: "retry" }; |
There was a problem hiding this comment.
Preserve persisted-turn state across overload retries
When a provider overload is thrown after the embedded runner has already persisted the queued user message but before any tool/output phase, this full-turn retry re-enters runAgentFallbackCandidates with its local queuedUserMessagePersistedAcrossFallback reset to false, so the next runEmbeddedAgent call gets suppressNextUserMessagePersistence: false and writes the same user turn again. The existing candidate-level latch protects fallback candidates within one pass; the new outer overload replay needs to carry that persisted-turn state before returning retry, otherwise a short outage can duplicate the user's prompt in the session transcript and make the recovered attempt answer a corrupted conversation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01b99e1269
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (info.phase === "tool_execution_started" || info.phase === "assistant_output_started") { | ||
| markOverloadRetryUnsafeToReplay(overloadRetryState); | ||
| } |
There was a problem hiding this comment.
Stop overload retries after CLI progress callbacks
When the active runtime is a CLI backend, assistant/tool progress is delivered through runCliAgentWithLifecycle callbacks (agent-runner-cli-candidate.ts:140 and agent-runner-cli-candidate.ts:168), while the CLI path does not emit these assistant_output_started/tool_execution_started phases. If that process later exits with an overloaded FailoverError after streaming text or tool progress, unsafeToReplay remains false here and the new overload retry replays the entire turn after observable output or tool activity already happened, duplicating messages or side effects. Mark the overload retry state unsafe from the CLI progress callbacks too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 392a13b5a6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| isOverloaded && | ||
| !params.overloadRetryState.unsafeToReplay && | ||
| params.overloadRetryState.retryCount < MAX_OVERLOAD_RETRIES | ||
| ) { |
There was a problem hiding this comment.
Clear deferred suspension before retrying overload summaries
When a configured fallback chain has more than one candidate and every candidate returns overloaded, runWithModelFallback creates the FallbackSummaryError only after calling suspendSession(...) in src/agents/model-fallback.ts:745, which can persist quotaSuspension and throttle the lane. This new retry path catches that same pure-overload summary and replays the turn; if a later retry succeeds, the earlier async suspension can still land and leave a recovered session/lane suspended for the default resume window. Avoid retrying these summaries without deferring or clearing the summary suspension.
Useful? React with 👍 / 👎.
| params.overloadRetryState.noticeSent = true; | ||
| turn.replyOperation?.recordActivity(); | ||
| const currentMessageId = turn.sessionCtx.MessageSidFull ?? turn.sessionCtx.MessageSid; | ||
| const noticePayload = markReplyPayloadForSourceSuppressionDelivery( |
There was a problem hiding this comment.
Route overload notices through suppression-aware delivery
For source-suppressed turns such as message_tool_only or room_event, this metadata is ignored because the notice is delivered through the progress onBlockReply callback; dispatch-from-config.ts:2444 returns immediately when suppressDelivery is true before the final-delivery deliverDespiteSourceReplySuppression check runs. In those contexts the long overload retry still waits silently despite the payload being marked to bypass source suppression, so the notice needs to use a delivery path that honors this marker or the progress path needs the same bypass check.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
* fix(auto-reply): retry provider overloads * fix(auto-reply): type notice delivery errors * fix(auto-reply): guard overload replay safety * fix(auto-reply): close overload retry races * test(auto-reply): inject operation abort signals * docs: leave overload note to release automation * test(auto-reply): cover capacity retry exhaustion
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]>
…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 #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]>
…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]>
* fix(auto-reply): retry provider overloads * fix(auto-reply): type notice delivery errors * fix(auto-reply): guard overload replay safety * fix(auto-reply): close overload retry races * test(auto-reply): inject operation abort signals * docs: leave overload note to release automation * test(auto-reply): cover capacity retry exhaustion
What Problem This Solves
Fixes an issue where users could receive a terminal temporary-overload reply after a model fallback chain was briefly exhausted, even though another attempt moments later would likely succeed. Longer recovery attempts also gave no progress signal.
Why This Change Was Made
Pure overload exhaustion now retries the complete turn-local candidate chain up to 10 times with bounded exponential backoff. After 30 seconds, one transient status notice explains that OpenClaw is still retrying. Full-turn retry and pending notices stop once tool execution or assistant output begins, preventing duplicate mutations or messages; aborts also cancel timers and close lifecycle state.
Fallback winners remain turn-local. Ordinary timeout and server-error behavior remains unchanged.
User Impact
Short provider overloads can recover without requiring the user to resend their message. If recovery takes longer, users receive one status update instead of waiting silently. Exhausted retries still return the existing overload error.
Evidence
AI-assisted change. I reviewed the implementation, safety boundaries, tests, and validation output.