Skip to content

fix(agents): own transient LLM retries in one failover retry controller - #134281

Merged
obviyus merged 10 commits into
mainfrom
fix/llm-retry-owner
Sep 1, 2026
Merged

obviyus merged 10 commits into
mainfrom
fix/llm-retry-owner

Conversation

@obviyus

@obviyus obviyus commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When a provider returns a transient failure (429, 5xx, or timeout), up to three uncoordinated retry layers replayed the same request:

  1. Software development kit (SDK) retries — OpenAI and Anthropic SDK clients ran with their default retry policies, invisible to OpenClaw.
  2. ChatGPT transport retry loop — openai-chatgpt-responses had its own per-request retry loop on top of the SDK.
  3. Outer overload replay — the reply runner replayed the whole turn up to 10 times, with backoff up to 30s, and posted a "still retrying" notice after 30s.

Stacked, these multiplied: one transient 429 could hold a turn silently for minutes with no coherent budget, and the failover controller (which owns provider/model fallback) never saw all the attempts it needed to budget. This follows #134103 and #134111 in the LLM error-UX series.

Why This Change Was Made

One retry owner, one budget. The embedded runner's failover retry controller (src/agents/embedded-agent-runner/run/failover-retry-controller.ts) owns transient-retry policy:

  • retry.provider.maxRetries is the transient-retry attempt budget. The controller installs the saved value for each dispatch. The default budget remains 3.
  • The retry window stays flat at 90s. The window bounds time-to-failover, not attempt count. When maybeRetryTransient returns false, the caller falls through to rotate_profile, fallback_model, or surface_error (src/agents/embedded-agent-runner/run/assistant-failover.ts:137-153). Exhaustion moves to another profile or model, which is better recovery than more same-model retries against a slow provider.
  • The default budget does not bind the window. Three jittered backoff delays total roughly 3.5–10.5s. resolveTransientRetryDelayMs uses a 1s base, 0.5–1.5x jitter, and a 30s cap (src/agents/embedded-agent-runner/run/helpers.ts:44-79). The window truncates only when requests themselves are slow, which is when failover is the right move.
  • Scaling the window with the configured budget would delay failover and make the worst case worse. The fixed window keeps time-to-failover bounded.
  • Window truncation is now recorded. Commit 7d7d6a5e8a2 logs the retry count and configured budget at the controller producer (src/agents/embedded-agent-runner/run/failover-retry-controller.ts:244-250), so a configured budget that cannot run fully is diagnosable. The regression is covered by src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts, records the truncation when the window ends a budget that still has attempts.

This is not a breaking change. A saved retry.provider.maxRetries keeps a coherent meaning: it was the per-SDK-request retry count, and it is now the transient-retry attempt budget owned by one controller. Before this PR, the value reached only the provider SDK and multiplied against a separate hardcoded controller retry of 3; it never reached OpenClaw's own retry owner. Saved values remain valid, with no migration, doctor repair, or config-shape change.

Other retry paths are consolidated around that owner:

  • SDK clients use maxRetries: 0. buildOpenAISdkClientOptions and buildOpenAISdkRequestOptions prevent SDK retries from hiding attempts from the owner.
  • The ChatGPT transport retry loop is deleted. The transport surfaces the classified error and carries Retry-After / retry-after-ms through the terminal error text, so the controller can honor provider pacing.
  • The obsolete StreamOptions.maxRetries knob is removed. The session runtime's retry.maxRetries loop remains separate because it has a different owner.
  • Outer overload replay is deleted (src/auto-reply/reply/agent-runner-error-handler.ts), along with OverloadRetryState and the 30s "still retrying" notice. Embedded runs use the inner controller; CLI harness backends own their internal retries, so escaping errors surface immediately with actionable copy.
  • Copy priority is fixed at both reply sites. Curated facet copy (providerRequestError.userMessage) beats the generic classified summary.
  • Silent failures use the same budget. A classified transient error with no visible output consults the retry owner instead of a parallel silent-retry counter. Only reasons the controller cannot classify keep the bounded local empty-error counter, capped at 3.
  • The 90s budget starts at the first consult. Failed-request time counts against it, not only backoff sleep.
  • Turn timing uses admission time. Terminal lifecycle backstops stamp AgentFallbackCycleState.turnStartedAtMs, so error events and session runtimeMs reflect the real turn duration.

Accepted tradeoffs (named, not accidental)

  • The 30s "still retrying" notice is gone. The new budget caps total transient waiting at 90s, below the threshold that made the notice useful.
  • Worst-case transient patience drops from about 217s to 90s. A persistent overload now fails visibly within 90s with actionable copy instead of a multi-minute silent replay.

User Impact

  • A transient provider blip retries quickly and quietly with bounded, jittered backoff and provider pacing, then succeeds or follows the existing failover chain.
  • A persistent outage surfaces within the 90s window with curated, actionable copy instead of minutes of silence.
  • A saved retry.provider.maxRetries controls the transient-retry attempt budget in one controller. A slow provider can end that budget at the flat window, and the controller records that truncation.
  • There is no silent multi-layer retry stacking. Each transient retry is owned and budgeted by one controller.
  • An unprepared provider HTTP 500 now reads "provider internal error" instead of "request timed out". The old copy came from the outer replay path attributing every escaping failure to a timeout; the classified facet now reaches the reply site unchanged.

Evidence

  • Live product-path proof (Telegram Test Server end-to-end run, real gateway with fault injection, rerun on this head): a real-user DM asked for OPENCLAW_E2E_OK only; the mock provider returned an injected transient HTTP 500 on the first /v1/responses request and a normal completion on the second. The gateway log showed transient same-model retry 1/3 for openai/gpt-5.5. Telegram received exactly one assistant reply, with no error and no duplicate. mock-openai-requests.ndjson contained exactly two provider requests. The same prompt without fault injection used exactly one provider request.
  • Silent idle timeout keeps its quiet same-model replay, now budgeted by the retry owner: an unclassified idle timeout consults maybeRetryTransient({ reason: "timeout" }) in src/agents/embedded-agent-runner/run/assistant-failover.ts instead of a second bespoke retry counter. The run-wide idle-timeout breaker still caps consecutive silent attempts at 5.
  • Fallback handoff tests use the new contract: a persistent command-line interface (CLI) server_error or prompt timeout exhausts the 3-retry budget, for 4 attempts total, and then throws FailoverError to the configured fallback.
  • packages/ai full suite: 115 files / 2103 tests green, including transport tests that prove one HTTP request per failure mode and preserve Retry-After evidence.
  • src/auto-reply/reply full suite: 257 files / 5323 passed, 1 skipped, green, including the CLI capacity-error path and removal of the outer replay tests.
  • src/agents/embedded-agent-runner/run full directory: green, including retry-owner budget, backoff, provider pacing, and wall-clock coverage.
  • ChatGPT transport: packages/ai/src/providers/openai-chatgpt-responses.retry.test.ts proves a 429 with retry-after: 7 preserves Retry-After: 7 seconds in one HTTP request, which the retry owner parses as 7000ms.
  • Silent-failure budget unification: the shared integration test retries a silent, side-effect-free server_error through the controller; src/agents/embedded-agent-runner/run/assistant-failure.test.ts is 21/21 green.
  • Turn-timing regression: the fallback preparation failure test fails before this fix when the backstop stamps failure time and passes when turnStartedAtMs is carried on the fallback cycle state.
  • src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts covers the new truncation record: records the truncation when the window ends a budget that still has attempts verifies the controller logs after 1/8 retries when the flat window ends before the configured budget.
  • Lint (including plugin-SDK boundary declaration files) is clean on all 58 changed files; git diff --check is clean; formatting is applied.
  • Production LOC delta, using *.test.ts and *owner-test-support.ts as test paths: +463 / -685 across 44 production files, net -222. Tests: +459 / -617 across 47 test files, net -158. Overall: +922 / -1302 across 91 changed files, net -380.

@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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 31, 2026
@obviyus
obviyus marked this pull request as ready for review August 31, 2026 16:39
@obviyus
obviyus force-pushed the fix/llm-retry-owner branch from e51f49d to ed0593f Compare August 31, 2026 16:47
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 1:49 AM ET / 05:49 UTC.

ClawSweeper review

What this changes

The branch centralizes transient provider retries in the embedded agent runner, disables overlapping SDK and native transport retries, and uses the existing session retry setting as a turn-wide retry budget.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open for maintainer review: the branch is not on current main and coherently removes stacked transient retry owners, but it intentionally changes the scope of an existing saved retry setting and needs explicit compatibility acceptance plus direct pinned-SDK contract verification before merge.

Priority: P1
Reviewed head: d03a45df2d0ab4b1adb17dd328206acceb5873e9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The retry design and Telegram proof are strong, but compatibility acceptance and direct verification of the configured pinned SDK contracts remain merge-relevant gaps.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed owner is the embedded-run retry controller; supplied PR evidence reports a Telegram Test Server fault-injection run with a first transient HTTP failure, one controller-driven retry, one visible reply, and a no-fault control, while source tests cover the controller and native transport boundaries.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed owner is the embedded-run retry controller; supplied PR evidence reports a Telegram Test Server fault-injection run with a first transient HTTP failure, one controller-driven retry, one visible reply, and a no-fault control, while source tests cover the controller and native transport boundaries.
Evidence reviewed 9 items Single retry owner: The introduced controller accepts only transient rate-limit, overload, server-error, and timeout classes; it applies one budget and 90-second window before allowing failover.
Caller and failure-route coverage: The run loop creates one controller per embedded run, installs the session-owned retry budget on each dispatch, and passes it into both prompt and assistant failure processing.
Native transport behavior: The ChatGPT Responses transport now performs one HTTP attempt, preserves Retry-After timing in terminal error text, and retains only encrypted-content semantic replay rather than transient request replay.
Findings None None.
Security None None.

How this fits together

OpenClaw’s embedded agent runner converts a channel turn into provider attempts, failover decisions, and a final channel reply. This change makes one controller own retry timing before a failed attempt can rotate credentials, switch models, or surface an error.

flowchart LR
  A[Channel turn] --> B[Embedded agent runner]
  B --> C[Provider attempt]
  C --> D{Transient failure}
  D -->|retryable| E[Shared retry controller]
  E --> C
  D -->|not retryable or exhausted| F[Profile or model failover]
  F --> G[Final channel reply]
Loading

Decision needed

Question Recommendation
Should existing retry.provider.maxRetries configurations be accepted as a turn-wide transient-retry budget, including a fixed 90-second ceiling, rather than as per-SDK-request retry counts? Accept centralized budget: Confirm the documented turn-wide budget and fixed ceiling are the intended upgrade behavior after direct SDK contract verification.

Why: This is a deliberate compatibility and operator-behavior change to a retained persisted setting; source review cannot decide whether that upgrade tradeoff is acceptable.

Before merge

  • Resolve merge risk (P1) - Existing retry.provider.maxRetries configurations change from SDK/request retry counts to a shared turn-wide budget that may stop early when the 90-second retry window expires.
  • Resolve merge risk (P1) - The checkout did not contain the pinned upstream SDK sources, so the review verified OpenClaw’s maxRetries: 0 calls but not each SDK’s runtime contract directly.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test delta production +469/-699 (net -230); tests/test support +478/-699 (net -221); docs -39 The substantial net-negative production diff comes from deleting duplicate retry loops while retaining focused regression coverage.
Persisted retry-setting behavior 1 existing setting changed retry.provider.maxRetries remains persisted but changes from a provider request option to the shared embedded-run retry budget.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the centralized upgrade contract (recommended)
    Verify the pinned SDK retry-disable contract and have an area owner explicitly accept the retained setting’s turn-wide 90-second behavior before merge.
  2. Retain legacy retry scope
    Pause this approach if preserving per-request retry semantics for existing saved settings is more important than one controller.

Technical review

Best possible solution:

Retain the single controller, explicitly accept the turn-wide saved-setting semantics, and verify the pinned SDK clients honor retry disabling before merge.

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

Yes—source and regression tests give a high-confidence path: trigger a replay-safe transient provider failure during an embedded run and observe the controller’s retry/failover decisions; this review did not execute it locally.

Is this the best way to solve the issue?

Yes for the duplicate-retry failure class: one controller makes accounting visible and bounded, contingent on confirming the retained SDK and saved-setting compatibility contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The change repairs transient provider-failure recovery on active agent turns, where stacked retries can delay a visible user outcome for minutes.
  • merge-risk: 🚨 compatibility: Existing persisted retry.provider.maxRetries values receive a different scope and a new fixed time ceiling after merge.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed owner is the embedded-run retry controller; supplied PR evidence reports a Telegram Test Server fault-injection run with a first transient HTTP failure, one controller-driven retry, one visible reply, and a no-fault control, while source tests cover the controller and native transport boundaries.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is the embedded-run retry controller; supplied PR evidence reports a Telegram Test Server fault-injection run with a first transient HTTP failure, one controller-driven retry, one visible reply, and a no-fault control, while source tests cover the controller and native transport boundaries.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Retry timing determines when a Telegram user receives a reply; supplied Telegram Test Server evidence is therefore directly relevant.

Evidence

Acceptance criteria:

  • [P1] Inspect the pinned OpenAI, Anthropic, and Mistral SDK retry-option contracts or run a direct contract check.
  • [P1] Validate an existing persisted retry.provider.maxRetries configuration across retry, profile rotation, and failover.

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)
  • Jason (Json): 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.

  • Verify from the pinned OpenAI, Anthropic, and Mistral SDK sources or a direct contract run that maxRetries: 0 disables internal retries.
  • Have an area owner confirm the retained setting’s turn-wide 90-second upgrade behavior.

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 (6 earlier review cycles)
  • reviewed 2026-08-31T16:56:11.927Z sha ed0593f692e663f6023a638e9c38f795eb6e67ec :: found issues before merge. :: [P1] Route zero-output server errors through the shared retry budget | [P1] Measure the retry budget from turn start | [P1] Do not silently discard the Sessions provider retry setting | [P2] Carry response retry hints out of the ChatGPT transport
  • reviewed 2026-08-31T17:21:48.265Z sha 59422dddc37d9376c4e44bb45817bf32a205147d :: needs changes before merge. :: [P1] Preserve the Sessions provider retry setting | [P1] Charge zero-output server errors to the shared retry budget | [P2] Preserve HTTP Retry-After evidence for native ChatGPT failures | [P2] Measure the retry ceiling from turn admission | [P2] Record the retry count after scheduling the assistant retry
  • reviewed 2026-08-31T17:54:00.599Z sha cca8551 :: found issues before merge. :: [P1] Update the SDK-options test call | [P1] Migrate the retired provider retry setting | [P2] Read the retry count after scheduling the retry
  • reviewed 2026-08-31T18:09:52.239Z sha 4cc0298 :: found issues before merge. :: [P1] Update the SDK-options test call | [P1] Migrate the retired provider retry preference | [P2] Read retry count after scheduling the retry
  • reviewed 2026-09-01T04:23:40.413Z sha 27c93e4 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T05:31:47.000Z sha d03a45d :: needs maintainer review before merge. :: none

@obviyus
obviyus force-pushed the fix/llm-retry-owner branch 2 times, most recently from 59422dd to cca8551 Compare August 31, 2026 17:45
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus
obviyus force-pushed the fix/llm-retry-owner branch from cca8551 to 4cc0298 Compare August 31, 2026 17:59
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 31, 2026
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review — all three findings addressed on head 94b957b (excess test inputs removed, retired retry.provider.maxRetries now stripped by the settings-storage owner under its lock, failover retry count reads live via getTransientRetryCount).

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…enclaw#135374)

Follow up on openclaw#134980 by computing attempt visibility and silent-reply eligibility once, removing duplicated empty-turn predicates and a one-call terminal-error wrapper. Align the failover docs with the consolidated transient retry owner from openclaw#134281. Production delta: -71 lines; no behavior or configuration change.
steipete added a commit that referenced this pull request Sep 3, 2026
Restore the shipped optional provider-wrapper input as deprecated without re-enabling nested text retries. Keep numeric callers source-compatible and document the future SDK-major removal gate. Correct the nearby header-wrapper example to forward model, context, and request options.

Production net0;217 focused tests, strict stable/baseline/candidate public SDK consumers, full changed gate, and independent managed review pass. Related: #134281.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
Restore the shipped optional provider-wrapper input as deprecated without re-enabling nested text retries. Keep numeric callers source-compatible and document the future SDK-major removal gate. Correct the nearby header-wrapper example to forward model, context, and request options.

Production net0;217 focused tests, strict stable/baseline/candidate public SDK consumers, full changed gate, and independent managed review pass. Related: openclaw#134281.
obviyus added a commit that referenced this pull request Sep 28, 2026
Closes #160534

## What Problem This Solves

Fixes repeated provider requests when an HTTP 400 response has an empty body, wasting rate limits and potentially hiding the original error behind subsequent throttling.

## User Impact

A deterministic bodyless client error now surfaces after one model request rather than four. Transient recovery, empty successful response repair, and normal replies retain their existing behavior. No configuration changes are required.

## Why This Change Was Made

The silent-error recovery path previously treated an unclassified bodyless HTTP 400 like a missing model response. It now checks the existing HTTP-status and transient-retry evidence owners before replaying a client error, without introducing another retryable-status list or reclassifying the failure as a format error.

The transport's existing retryable HTTP-status predicate is shared with the silent-error guard, preserving bodyless 409 conflict recovery without changing the transport's SDK wait cap or the transient retry budget.

The reasoning-only, replay-safe recovery introduced in #92191 remains intact, as does the separate transient recovery budget from #134281 and #139397.

Thanks to @bogdandragosvasile for the exact local reproduction. No overlap with Pash/Sarah changes.

## Evidence

Ran `pnpm openclaw --profile <isolated-profile> agent exec` against the issue's local empty-body fault server, using task-owned config, state, home, workspace, and ports. Baseline: `25d771cb8203f5afeea7b7c9dc8060210db8e43d`.

| Provider response | Baseline model requests | Fixed model requests | Observed result |
| --- | ---: | ---: | --- |
| Empty HTTP 400 | 4 | 1 | Original `400 status code (no body)` surfaces |
| Empty HTTP 409 | 4 | 4 | Existing silent-error retries, then original conflict error |
| Empty HTTP 429 | 10 | 10 | Existing transient retries, then rate-limit error |
| Empty HTTP 200 | 2 | 2 | Existing visible-answer retry, then incomplete-response error |
| Normal streamed HTTP 200 | 1 | 1 | `pong` |

Counts are `POST /v1/chat/completions` requests; unrelated `GET /` probes are excluded. Baseline controls were run with the production change reverted in the same worktree.

The new bodyless 400/422 owner regressions both failed before the fix (`retry` instead of `proceed`) and pass afterward. The focused run of `run.owner-policy.test.ts`, `failover/classify.test.ts`, and `provider-transport-fetch.test.ts` with `pnpm test ... --maxWorkers=1` passed all 133 tests in 40.6 seconds total wall time including worker compilation. This includes the new 409 preservation case, existing reasoning-only and replay-unsafe-tool cases, and existing SDK retry-cap tests.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
Closes openclaw#160534

## What Problem This Solves

Fixes repeated provider requests when an HTTP 400 response has an empty body, wasting rate limits and potentially hiding the original error behind subsequent throttling.

## User Impact

A deterministic bodyless client error now surfaces after one model request rather than four. Transient recovery, empty successful response repair, and normal replies retain their existing behavior. No configuration changes are required.

## Why This Change Was Made

The silent-error recovery path previously treated an unclassified bodyless HTTP 400 like a missing model response. It now checks the existing HTTP-status and transient-retry evidence owners before replaying a client error, without introducing another retryable-status list or reclassifying the failure as a format error.

The transport's existing retryable HTTP-status predicate is shared with the silent-error guard, preserving bodyless 409 conflict recovery without changing the transport's SDK wait cap or the transient retry budget.

The reasoning-only, replay-safe recovery introduced in openclaw#92191 remains intact, as does the separate transient recovery budget from openclaw#134281 and openclaw#139397.

Thanks to @bogdandragosvasile for the exact local reproduction. No overlap with Pash/Sarah changes.

## Evidence

Ran `pnpm openclaw --profile <isolated-profile> agent exec` against the issue's local empty-body fault server, using task-owned config, state, home, workspace, and ports. Baseline: `f6f301f702dfed02b63423237db57f96e8f4145a`.

| Provider response | Baseline model requests | Fixed model requests | Observed result |
| --- | ---: | ---: | --- |
| Empty HTTP 400 | 4 | 1 | Original `400 status code (no body)` surfaces |
| Empty HTTP 409 | 4 | 4 | Existing silent-error retries, then original conflict error |
| Empty HTTP 429 | 10 | 10 | Existing transient retries, then rate-limit error |
| Empty HTTP 200 | 2 | 2 | Existing visible-answer retry, then incomplete-response error |
| Normal streamed HTTP 200 | 1 | 1 | `pong` |

Counts are `POST /v1/chat/completions` requests; unrelated `GET /` probes are excluded. Baseline controls were run with the production change reverted in the same worktree.

The new bodyless 400/422 owner regressions both failed before the fix (`retry` instead of `proceed`) and pass afterward. The focused run of `run.owner-policy.test.ts`, `failover/classify.test.ts`, and `provider-transport-fetch.test.ts` with `pnpm test ... --maxWorkers=1` passed all 133 tests in 40.6 seconds total wall time including worker compilation. This includes the new 409 preservation case, existing reasoning-only and replay-unsafe-tool cases, and existing SDK retry-cap tests.

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 extensions: github-copilot extensions: meta Extension: meta extensions: moonshot 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant