Skip to content

fix(agents): single-source model fallback availability - #134111

Merged
obviyus merged 7 commits into
mainfrom
fix/fallback-config-truth
Aug 31, 2026
Merged

obviyus merged 7 commits into
mainfrom
fix/fallback-config-truth

Conversation

@obviyus

@obviyus obviyus commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The "are model fallbacks available" fact was derived twice with different rules:

  1. resolveEffectiveModelFallbacks (src/agents/agent-scope.ts) returned an empty ladder when the session carried a user model override.
  2. hasConfiguredModelFallbacks — feeding fallbackConfigured in src/agents/embedded-agent-runner/run-orchestrator.ts — did not apply the override rule.

So a gateway with configured fallbacks and a user-pinned model ran the whole failover policy with fallbackConfigured=true while the ladder the outer runner consumed was empty. This is not a diagnostics-only bug: fallbackConfigured is a behavioral input to resolveRunFailoverDecision (run/failover-policy.ts retry-limit escalation) and to the rate-limit rotation cap (run/failover-retry-controller.ts:160), so the split-brain changed what the user saw:

  • Pre-fix product path (proven at the boundary): pinned model + rate-limited provider → at the profile-rotation cap, the controller "escalated to model fallback" over the empty ladder — it threw the escalation error (The AI service is temporarily rate-limited. Please try again in a moment., no suspend) after two attempts, the outer runner recorded chain_exhausted with no next candidate and rethrew. The run skipped its remaining same-model retry budget and never entered the real rate-limit surface.
  • Same shape at the retry limit: failover-policy.ts selected fallback_model → run/retry-limit.ts threw a FailoverError instead of returning the normal retry-limit payload.
  • And nothing anywhere recorded why no fallback fired. Real incident: configured Anthropic fallbacks, provider failure surfaced to the user, zero fallback attempts, zero explanation in logs.

Why This Change Was Made

The pinned-override semantic is intentional (a pinned model must not silently switch). The bug is the split-brain derivation and the silence. Fix:

  • One resolver, resolveModelFallbackAvailability, returns a closed union: { kind: "active", models } | { kind: "none_configured" } | { kind: "disabled_by_model_override" } | { kind: "disabled_by_model_selection_lock" } — computed once where the run scope is prepared and carried on RunEmbeddedAgentParams as a prepared fact.
  • resolveEffectiveModelFallbacks and the orchestrator's fallbackConfigured are now projections of that one result; the duplicate hasConfiguredModelFallbacks and hasEmbeddedRunConfiguredModelFallbacks (run/fallbacks.ts) derivations are deleted, so disagreement is unrepresentable.
  • When the state is disabled_by_model_override, the orchestrator logs it once per run ([model-fallback] configured fallbacks disabled by user model override), so an operator reading logs during an incident learns why no fallback fired.
  • Fallback-notice truthfulness was audited and proven already correct: resolveFallbackTransition requires a real selected→active model difference before any chat notice or lifecycle event fires (src/auto-reply/fallback-state.ts, src/auto-reply/reply/agent-runner-result-payloads.ts); no change needed, group/channel notice suppression untouched.

User Impact

Pinned-model sessions with configured default fallbacks now get honest failure behavior. On a rate-limited provider the run spends its full same-model retry and profile-rotation budget and then surfaces the real rate-limit copy (⚠️ API rate limit reached. Please try again later.) with proper suspend/cooldown semantics — instead of aborting early with a bogus "escalating to model fallback" error over a ladder that was empty all along. At the retry limit, the run returns the normal retry-limit payload instead of a thrown escalation error. The ladder semantics themselves (pinned override disables fallbacks, auto provenance keeps them) are preserved exactly, and operators gain one explanatory log line when configured fallbacks are suppressed by a pinned model.

Evidence

Boundary regression (embedded runner surface, fail-pre-fix proven): src/agents/model-fallback.run-embedded.e2e.test.ts — real orchestrator/run-loop/failover controller, only runEmbeddedAttempt mocked:

  • "keeps a pinned model on its rate-limit surface instead of escalating to fallback" — configured default fallbacks, empty effective ladder, disabled_by_model_override prepared fact, multi-profile rate-limit faults. Asserts the run rejects with the real rate-limit surface (API rate limit reached, reason: "rate_limit", suspend: true), spends >2 primary attempts, attempts only the pinned provider, and records a chain_exhausted observation with no fallbackStepToModel. Pre-fix (production files checked out from the merge base bbd3410c067) this test fails for the intended reason: the run rejects with the rotation-cap escalation error The AI service is temporarily rate-limited. Please try again in a moment. (suspend: undefined) thrown from failover-retry-controller.ts under the bogus fallbackConfigured=true.
  • "keeps fallback enabled for an auto-selected model route" — sibling guard: same runner, { kind: "active" } fact → fallback engages and the groq candidate answers.
  • Full suite (22 tests) green on head: node scripts/run-vitest.mjs src/agents/model-fallback.run-embedded.e2e.test.ts.

Unit regression (fail-pre-fix proven): with source changes stashed, node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/fallbacks.test.ts failed with expected true to be false — the old configured signal reported true while the resolved ladder was empty under a user override. Post-fix the disagreement is structurally impossible.

Post-fix, independently rerun: src/agents/agent-scope.test.ts (54), src/auto-reply/reply/agent-runner-utils.test.ts, src/agents/model-fallback.test.ts + candidates/terminal-boundary/observation siblings, src/auto-reply/fallback-state.test.ts — all green. node scripts/check-changed.mjs --dry-run classified core/coreTests lanes; oxfmt and git diff --check clean.

Shipped-entry product path (unbroken chain): src/agents/model-fallback.reply-entry.e2e.test.ts drives a Telegram DM turn through the real reply entry with no bridges: getReplyFromConfig → followup queue → runReplyAgent → run-params (resolveModelFallbackOptions) → runEmbeddedAgent → real orchestrator/run-loop/failover controller, with only the attempt layer (runEmbeddedAttempt), model resolution, and environment seams mocked — the same seams the boundary suite uses. Setup: a session entry persisted through the shipped session store pins openai/mock-1 with modelOverrideSource: "user" while config declares fallbacks: ["anthropic/mock-2"]; the mocked attempt returns persistent rate-limit failures. Asserts the user-visible reply text contains API rate limit reached, >2 openai attempts, and zero anthropic attempts. Pre-fix this chain returned the rotation-cap escalation copy (The AI service is temporarily rate-limited. Please try again in a moment.) because run preparation rebuilt fallbackConfigured from config defaults instead of carrying the disabled availability fact.

Inherited-fallbacks provenance repair (ClawSweeper P1, confirmed real): the refactor's first cut collapsed inherited default fallbacks into an explicit run override in reply/command preparation. The candidate resolver (src/agents/model-fallback-candidates.ts:343,370) treats fallbacksOverride === undefined as "derive configured fallbacks and append the configured primary as the final candidate" — so a selected route C with default primary A + fallbacks [B] regressed from C→B→A to C→B. Repair: ModelFallbackAvailability now records provenance (source: "explicit" | "inherited" on active/none_configured), and one canonical projection modelFallbackOverrideFromAvailability maps inherited→undefined (resolver owns the ladder), explicit→models/[], disabled→[]. resolveEffectiveModelFallbacks is that projection composed over the availability resolver, restoring its pre-refactor string[] | undefined contract — so command prep (src/agents/command/run-embedded-attempt.ts) and codex diagnostics were repaired with zero call-site changes, and cron's tail collapsed back to a single resolveEffectiveModelFallbacks call. Regression coverage: projection truth-table rows in agent-scope.test.ts, and a chain-retention test in model-fallback.test.ts proving inherited fallbacks produce undefined and the candidate chain keeps the configured-primary tail (C→B→A) — sibling to the existing "does not append configured primary when fallbacksOverride is set" guard.

Channel-visible proof: the changed path is fully covered from the shipped reply entry through the embedded-runner boundary with real orchestrator/controller code and fault injection; the affected copy strings are asserted exactly there.

Post-repair reruns, all green: agent-scope.test.ts (60), model-fallback.test.ts (154+), agent-runner-utils.test.ts (87), prepared-model-runtime.reply-fallback.test.ts, run-fallback-policy.test.ts + run.payload-fallbacks.test.ts, config.plugin-validation.test.ts, agent-command.live-model-switch.test.ts (129), both model-fallback e2e suites (23), agent-runner.runreplyagent.e2e.test.ts (169), full src/cron/isolated-agent (43 files).

Production LOC net +54 vs merge base (closed provenance union + carried fact + canonical projection + one log line, minus deleted duplicate derivations); tests net +392 (boundary/e2e regression scenarios and the shipped-entry chain suite).

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@obviyus
obviyus marked this pull request as ready for review August 31, 2026 12:45
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 31, 2026, 11:31 AM ET / 15:31 UTC.

ClawSweeper review

What this changes

The PR centralizes model-fallback availability for reply runs, embedded execution, completion metadata, and cron routing so pinned user model overrides do not advertise unavailable fallback behavior.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the prior P1 compatibility regression remains on the latest head. The new reply-entry test covers pinned-model suppression, but active fallbacks inherited from defaults still lose the configured-primary candidate.

Priority: P1
Reviewed head: 56ce41d5a648c37f9f06d6e7e4b9625fd943a4ef

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has a credible owner-boundary repair and focused tests, but an unresolved P1 fallback compatibility regression blocks merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply. The supplied mocked-attempt tests do not cover the remaining inherited-default candidate-chain regression.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply. The supplied mocked-attempt tests do not cover the remaining inherited-default candidate-chain regression.
Evidence reviewed 5 items Introduced compatibility trigger: The PR projects every active availability result to an explicit fallback list. That changes inherited default fallbacks from undefined to a concrete list, including in the normal reply candidate path.
Candidate-chain contract: An explicit fallback list prevents the candidate builder from appending the configured primary; only an undefined override preserves that final candidate.
Reachable reply path: The channel reply fallback path passes the projected list to the embedded entry, which passes it to the model-fallback runner and candidate-chain resolver.
Findings 1 actionable finding [P1] Preserve the configured primary for inherited default fallbacks
Security None None.

How this fits together

A channel reply is prepared with its session model selection, then run through the embedded agent fallback loop. The fallback selection determines which models are attempted and whether retry policy surfaces an error or advances to another candidate.

flowchart LR
  A[Channel reply and session] --> B[Reply run preparation]
  B --> C[Fallback availability]
  C --> D[Candidate chain]
  D --> E[Embedded agent retry policy]
  E --> F[Reply result]
Loading

Before merge

  • Preserve the configured primary for inherited default fallbacks (P1) - When availability is active only because defaults supply fallbacks, this now passes a concrete list. resolveModelCandidateChain treats that as authoritative and skips its configured-primary append, changing the existing C→B→A recovery chain to C→B. Keep source provenance so inherited defaults remain undefined, and cover this reply path. This is the still-unfixed prior P1 finding.
  • Resolve merge risk (P2) - For a selected model C with default fallback B and configured primary A, merging changes the candidate order from C→B→A to C→B, so a valid recovery route disappears.
  • Resolve merge risk (P1) - The PR is production +97/-74 (net +23); the added typed fact is directionally sound, but the source distinction needed to retain inherited behavior is incomplete.
  • Complete next step (P2) - A narrow mechanical repair can preserve fallback-source provenance and add the missing behavior regression without changing public configuration.

Findings

  • [P1] Preserve the configured primary for inherited default fallbacks — src/auto-reply/reply/agent-runner-run-params.ts:47-48
Agent review details

Security

None.

PR surface

Source +169, Tests +142. Total +311 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 11 243 74 +169
Tests 6 452 310 +142
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 695 384 +311

Review metrics

Metric Value Why it matters
Production versus test delta production +97/-74 (net +23); tests and test support +598/-310 (net +288) The new availability boundary adds production code while substantially expanding regression coverage; the compatibility distinction must be repaired before that growth is justified.

Merge-risk options

Maintainer options:

  1. Preserve inherited fallback mode (recommended)
    Carry fallback-source provenance and retain an undefined override for default-inherited fallbacks, then prove the configured primary remains reachable after an alternate selected model and its fallback fail.

Technical review

Best possible solution:

Keep one prepared availability fact, but preserve whether active models came from an explicit override versus inherited defaults; pass undefined to the candidate builder for the inherited case so it retains the configured primary.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: configure a primary A and default fallback B, select a different model C, and exhaust C then B. The introduced explicit override suppresses the candidate builder's existing configured-primary append.

Is this the best way to solve the issue?

No. Centralizing availability is the right owner-boundary direction, but its current active result drops the provenance that distinguishes inherited defaults from an explicit override.

Full review comments:

  • [P1] Preserve the configured primary for inherited default fallbacks — src/auto-reply/reply/agent-runner-run-params.ts:47-48
    When availability is active only because defaults supply fallbacks, this now passes a concrete list. resolveModelCandidateChain treats that as authoritative and skips its configured-primary append, changing the existing C→B→A recovery chain to C→B. Keep source provenance so inherited defaults remain undefined, and cover this reply path. This is the still-unfixed prior P1 finding.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c884d51b870b.

Labels

Label justifications:

  • P1: The PR can remove a configured model-recovery route from ordinary active agent replies.
  • merge-risk: 🚨 compatibility: It changes inherited fallback semantics for existing model configurations without preserving the configured-primary candidate.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Repository state identifies this as a member-authored PR, so the external-contributor proof gate does not apply. The supplied mocked-attempt tests do not cover the remaining inherited-default candidate-chain regression.

Evidence

Acceptance criteria:

  • [P2] node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-utils.test.ts src/agents/model-fallback.test.ts.
  • [P2] node scripts/run-vitest.mjs src/agents/model-fallback.run-embedded.e2e.test.ts src/agents/model-fallback.reply-entry.e2e.test.ts.
  • [P2] node scripts/check-changed.mjs --dry-run -- src/auto-reply/reply/agent-runner-run-params.ts src/agents/model-fallback-candidates.ts.

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve inherited-default versus explicit-override provenance through both reply preparation paths.
  • Add a regression proving C→B→A remains reachable when defaults supply B.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-31T12:53:01.711Z sha 8c5c762 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T13:25:00.054Z sha 47408fa :: found issues before merge. :: [P1] Preserve the implicit fallback mode for channel-selected models
  • reviewed 2026-08-31T14:31:33.219Z sha 45ef270 :: found issues before merge. :: [P1] Preserve inherited fallback mode for selected models
  • reviewed 2026-08-31T15:15:27.008Z sha 77f3b09 :: found issues before merge. :: [P1] Preserve inherited fallback mode for selected models

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 31, 2026
A pinned-model session with configured default fallbacks now proves at the
embedded runner surface that no fallback escalation fires: pre-fix the
rate-limit rotation cap escalated to fallback_model over the empty ladder
and threw the escalation error after two attempts; post-fix the run spends
its full same-model retry budget and surfaces the real rate-limit copy
with suspend semantics. Sibling guard keeps fallback engaged for auto
provenance.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
The embedded-runner fallback e2e file crossed the max-lines lint cap;
the mock-free config/workspace/auth-store helpers move to a colocated
test-support module with grep-unique exported names.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. label Aug 31, 2026
Reply/command preparation collapsed inherited default fallbacks into an
explicit run override, so the candidate resolver stopped appending the
configured primary (C->B->A regressed to C->B). Tag availability with
explicit/inherited provenance, project it through the new
modelFallbackOverrideFromAvailability, and restore
resolveEffectiveModelFallbacks to its string[]|undefined contract so
command prep and codex diagnostics repair with zero call-site changes.
Cron collapses back to a single resolveEffectiveModelFallbacks call.
@obviyus
obviyus merged commit 5454da8 into main Aug 31, 2026
419 of 423 checks passed
@obviyus
obviyus deleted the fix/fallback-config-truth branch August 31, 2026 16:23
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @obviyus!

Proof: Boundary e2e through the real orchestrator/run-loop/failover controller plus a shipped-entry Telegram reply-chain test; both fail on the merge base for the intended reason and pass on the merged head. Full CI green on the exact head.

  • Bug: A session pinned to one model with configured default fallbacks ran failover policy believing fallbacks existed while the actual ladder was empty — on a rate-limited provider the run aborted early with a bogus "escalating to model fallback" error and never reached the real rate-limit surface, with no log explaining why no fallback fired.
  • Fix: One resolver (resolveModelFallbackAvailability) computes fallback availability once at run-scope preparation as a closed union; every consumer projects from it, the duplicate derivations are deleted, and a suppressed ladder is logged once per run.
Before After
Pinned model + rate-limited provider: early abort with "The AI service is temporarily rate-limited. Please try again in a moment." (no suspend), remaining retry budget skipped, zero explanation in logs Full same-model retry and profile-rotation budget spent, then the real "⚠️ API rate limit reached. Please try again later." surface with proper suspend/cooldown; operators see one log line when a pinned model disables configured fallbacks

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
The "are model fallbacks available" fact was derived twice with different
rules: resolveEffectiveModelFallbacks emptied the ladder under a user model
override while the orchestrator's fallbackConfigured signal did not, so
pinned-model runs executed failover policy against a ladder that was empty.
On a rate-limited provider the run aborted early with a bogus
"escalating to model fallback" error instead of spending its retry budget
and surfacing the real rate-limit copy with suspend semantics.

One resolver, resolveModelFallbackAvailability, now returns a closed union
computed once at run-scope preparation and carried as a prepared fact; the
duplicate derivations are deleted and disagreement is unrepresentable.
disabled_by_model_override is logged once per run so operators learn why no
fallback fired.

Evidence: fail-pre-fix boundary e2e (model-fallback.run-embedded.e2e.test.ts)
plus shipped-entry Telegram reply chain proof (model-fallback.reply-entry
.e2e.test.ts); sibling and unit suites green on the exact head.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Sep 1, 2026
…er (#134281)

Three uncoordinated retry layers replayed the same provider request on a transient failure: provider SDK client defaults, a per-request retry loop inside the ChatGPT transport, and an outer whole-turn replay in the reply runner. Stacked, one transient 429 could hold a turn silently for minutes, and the failover controller that owns provider/model fallback never saw the attempts it needed to budget.

Transient retry now has one owner: the embedded runner's failover retry controller. `retry.provider.maxRetries` is its attempt budget (default 3), the retry window stays flat at 90s so time-to-failover stays bounded, and window truncation is recorded at the producer. SDK clients run with `maxRetries: 0`, the ChatGPT transport loop is deleted, and the outer overload replay plus `OverloadRetryState` and the obsolete `StreamOptions.maxRetries` knob are removed.

User impact: a transient blip retries quickly and quietly, then succeeds or follows the existing failover chain; a persistent outage surfaces within 90s with curated, actionable copy instead of minutes of silence. An unprepared provider HTTP 500 now reads "provider internal error" instead of "request timed out". Not a breaking change: a saved `retry.provider.maxRetries` keeps a coherent meaning and needs no migration.

Named tradeoffs: the 30s "still retrying" notice is gone, and worst-case transient patience drops from about 217s to 90s.

Production LOC: +463 / -685 across 44 files, net -222.

Follows #134103 and #134111 in the LLM error-UX series.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…er (openclaw#134281)

Three uncoordinated retry layers replayed the same provider request on a transient failure: provider SDK client defaults, a per-request retry loop inside the ChatGPT transport, and an outer whole-turn replay in the reply runner. Stacked, one transient 429 could hold a turn silently for minutes, and the failover controller that owns provider/model fallback never saw the attempts it needed to budget.

Transient retry now has one owner: the embedded runner's failover retry controller. `retry.provider.maxRetries` is its attempt budget (default 3), the retry window stays flat at 90s so time-to-failover stays bounded, and window truncation is recorded at the producer. SDK clients run with `maxRetries: 0`, the ChatGPT transport loop is deleted, and the outer overload replay plus `OverloadRetryState` and the obsolete `StreamOptions.maxRetries` knob are removed.

User impact: a transient blip retries quickly and quietly, then succeeds or follows the existing failover chain; a persistent outage surfaces within 90s with curated, actionable copy instead of minutes of silence. An unprepared provider HTTP 500 now reads "provider internal error" instead of "request timed out". Not a breaking change: a saved `retry.provider.maxRetries` keeps a coherent meaning and needs no migration.

Named tradeoffs: the 30s "still retrying" notice is gone, and worst-case transient patience drops from about 217s to 90s.

Production LOC: +463 / -685 across 44 files, net -222.

Follows openclaw#134103 and openclaw#134111 in the LLM error-UX series.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant