Skip to content

fix: fail over instead of waiting on long rate limits - #152983

Closed
jzmudzinski wants to merge 1 commit into
openclaw:mainfrom
jzmudzinski:fix/sc-2741-rate-limit-failover
Closed

jzmudzinski wants to merge 1 commit into
openclaw:mainfrom
jzmudzinski:fix/sc-2741-rate-limit-failover

Conversation

@jzmudzinski

Copy link
Copy Markdown

Summary

  • let configured model fallbacks handle rate limits whose Retry-After exceeds 60 seconds
  • keep short same-model retries and single-model long waits unchanged
  • cover the 105,340,000 ms provider floor that previously stalled a turn until its watchdog aborted it

Testing

  • pnpm exec vitest run src/agents/embedded-agent-runner/run/failover-retry-controller.test.ts (32 passed)
  • pnpm tsgo:core
  • focused oxfmt --check and oxlint

Refs sc-2741.

@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 10:52 PM ET / September 30, 2026, 02:52 UTC.

ClawSweeper review

What this changes

The branch makes the embedded agent runner leave a same-model rate-limit wait for a configured model fallback when the provider requests more than 60 seconds, and adds controller tests.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep this PR open. PR close coverage proof kept this PR open against #148580: model PR close coverage proof was incomplete: PR B carries PR A's useful failover behavior in the merged implementation while addressing the material safety concerns identified in PR A's report. PR A's fixed 60-second cutoff is not distinct work that still needs review.

Priority: P2
Reviewed head: bb8b86bbd76584b0eb743ee7fd19c5d8dc8117c2

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The branch has focused controller coverage, but lacks real-run proof and conflicts with the released configurable, replay-safe fix.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused controller tests, typechecking, and linting, but no after-fix run through the embedded agent with a provider fault and observed fallback. The merged replacement has separate production-runner fault-sequence evidence; it is not proof supplied for this branch. If a distinct replacement is proposed, add redacted runtime output or a terminal capture of the affected turn; a PR-body update should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused controller tests, typechecking, and linting, but no after-fix run through the embedded agent with a provider fault and observed fallback. The merged replacement has separate production-runner fault-sequence evidence; it is not proof supplied for this branch. If a distinct replacement is proposed, add redacted runtime output or a terminal capture of the affected turn; a PR-body update should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 10 items PR close coverage proof: PR close coverage proof kept this PR open against #148580: model PR close coverage proof was incomplete: PR B carries PR A's useful failover behavior in the merged implementation while addressing the material safety concerns identified in PR A's report. PR A's fixed 60-second cutoff is not distinct work that still needs review.
Introduced branch behavior: The PR adds a fixed 60-second cutoff when a fallback is configured; it does not consult the saved cap or replay eligibility.
Current-main replacement: Current main uses the positive saved retry-delay cap and requires replay-safe fallback before declining a long rate-limit wait.
Findings 2 actionable findings [P1] Use the saved retry-delay cap
[P1] Keep replay-unsafe attempts on the continuation path
Security None None.

How this fits together

The embedded agent runner receives provider failures and retry timing hints during a model turn. Its retry controller decides whether to wait on the current model or return control to auth-profile and model fallback.

flowchart LR
  A[Provider rate limit] --> B[Retry timing hint]
  B --> C[Embedded retry controller]
  D[Saved retry cap] --> C
  E[Replay safety] --> C
  C --> F[Wait and continue]
  C --> G[Eligible fallback]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused controller tests, typechecking, and linting, but no after-fix run through the embedded agent with a provider fault and observed fallback. The merged replacement has separate production-runner fault-sequence evidence; it is not proof supplied for this branch. If a distinct replacement is proposed, add redacted runtime output or a terminal capture of the affected turn; a PR-body update should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Use the saved retry-delay cap (P1) - The introduced 60-second constant overrides retry.provider.maxRetryDelayMs: a configured longer cap or disabled cap can still trigger fallback. Use the saved positive cap so existing settings retain their meaning.
  • Keep replay-unsafe attempts on the continuation path (P1) - When a turn has replay-unsafe tool activity, this shortcut returns false solely because a fallback is configured. Recovery then cannot safely fall back and may end the turn instead of waiting and continuing its transcript; gate the shortcut on current replay eligibility.
  • Complete close-coverage proof - Complete the pull request close-coverage proof before merge.

Findings

  • [P1] Use the saved retry-delay cap — src/agents/embedded-agent-runner/run/failover-retry-controller.ts:276-280
  • [P1] Keep replay-unsafe attempts on the continuation path — src/agents/embedded-agent-runner/run/failover-retry-controller.ts:276-285
Agent review details

Security

None.

PR surface

Source +12, Tests +37. Total +49 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 0 +12
Tests 1 37 0 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 0 +49

Review metrics

Metric Value Why it matters
Retry cutoff 1 new fixed 60-second threshold It conflicts with the existing configurable retry-delay cap.
Production versus test growth production +12, tests +37 The production growth duplicates behavior now owned by the merged cap-aware fix.

Root-cause cluster

Relationship: superseded
Canonical: #148580
Summary: A merged PR covers the same long rate-limit wait through the configured cap and replay-safe fallback path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep this PR open until a linked canonical PR proves it covers this PR's unique work, or a maintainer confirms closure.

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

No current-main reproduction was established in this read-only review. Current source and the embedded-runner fault-sequence coverage show the reported long-header case following the configured fallback.

Is this the best way to solve the issue?

No for this branch: its fixed cutoff ignores the existing setting and replay-safety state. The merged cap-aware implementation is the narrower solution.

Full review comments:

  • [P1] Use the saved retry-delay cap — src/agents/embedded-agent-runner/run/failover-retry-controller.ts:276-280
    The introduced 60-second constant overrides retry.provider.maxRetryDelayMs: a configured longer cap or disabled cap can still trigger fallback. Use the saved positive cap so existing settings retain their meaning.
    Confidence: 0.97
  • [P1] Keep replay-unsafe attempts on the continuation path — src/agents/embedded-agent-runner/run/failover-retry-controller.ts:276-285
    When a turn has replay-unsafe tool activity, this shortcut returns false solely because a fallback is configured. Recovery then cannot safely fall back and may end the turn instead of waiting and continuing its transcript; gate the shortcut on current replay eligibility.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 53ccbd1b7b1f; fix evidence: release v2026.9.6, commit fcc927f58d02.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The branch's fixed cutoff can override an operator's saved retry-delay cap, including a disabled cap.
  • add merge-risk: 🚨 availability: Declining the wait after replay-unsafe tool activity can end a turn that should continue its transcript.

Label justifications:

  • P2: The underlying failure affected model fallback, but current main and the latest release contain the replacement fix.
  • merge-risk: 🚨 compatibility: The branch's fixed cutoff can override an operator's saved retry-delay cap, including a disabled cap.
  • merge-risk: 🚨 availability: Declining the wait after replay-unsafe tool activity can end a turn that should continue its transcript.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused controller tests, typechecking, and linting, but no after-fix run through the embedded agent with a provider fault and observed fallback. The merged replacement has separate production-runner fault-sequence evidence; it is not proof supplied for this branch. If a distinct replacement is proposed, add redacted runtime output or a terminal capture of the affected turn; a PR-body update should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

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

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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 25, 2026
@jzmudzinski

Copy link
Copy Markdown
Author

Closing as superseded by #148580, which landed a configurable, replay-safe version of the same failover behavior. Thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant