Skip to content

fix: recover from temporary provider overloads - #109354

Merged
steipete merged 9 commits into
mainfrom
codex/overload-retry-progress
Jul 16, 2026
Merged

steipete merged 9 commits into
mainfrom
codex/overload-retry-progress

Conversation

@steipete

@steipete steipete commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L maintainer Maintainer-authored PR labels Jul 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +186 to +188
if (info.phase === "tool_execution_started" || info.phase === "assistant_output_started") {
markOverloadRetryUnsafeToReplay(overloadRetryState);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +264 to +268
if (
isOverloaded &&
!params.overloadRetryState.unsafeToReplay &&
params.overloadRetryState.retryCount < MAX_OVERLOAD_RETRIES
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@steipete
steipete merged commit 7a45a65 into main Jul 16, 2026
190 of 192 checks passed
@steipete
steipete deleted the codex/overload-retry-progress branch July 16, 2026 22:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
* 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
steipete pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Jul 17, 2026
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]>
steipete added a commit that referenced this pull request Jul 17, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
…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]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant