Skip to content

Feature: configurable LLM retry with backoff on transient errors (overloaded/529) #49376

Closed
BingqingLyu/openclaw
#995

Description

@zenfish

Summary

When Anthropic returns a transient error (HTTP 529 overloaded, 503, or 500), the gateway currently classifies it and surfaces the error to the user. There's no configurable retry-with-backoff for the main LLM request path.

Current behavior

  • Cron jobs have cron.retry with configurable maxAttempts, backoffMs, and retryOn — great design.
  • Channel message delivery has retry config (attempts, minDelayMs, maxDelayMs, jitter).
  • The generic retryAsync infra exists in src/infra/retry.ts.
  • Main LLM conversation requests have no exposed retry config for transient provider errors.

Proposed behavior

Add an agent-level (or global) retry config for LLM requests on transient errors:

{
  "agents": {
    "defaults": {
      "llmRetry": {
        "enabled": true,
        "maxAttempts": 5,
        "backoffMs": [60000, 60000, 120000, 180000, 300000],
        "retryOn": ["overloaded", "server_error", "network"],
        "maxTotalMs": 900000
      }
    }
  }
}

Key properties:

  • backoffMs: Array of delays between retries (supports Fibonacci-style or custom progression)
  • retryOn: Which error classes to retry (reuse existing classification: overloaded, server_error, network, timeout)
  • maxTotalMs: Total wall-clock cap to prevent infinite waits
  • Should NOT retry on: rate_limit (quota, not transient), auth, billing, format errors

Why this matters

During Anthropic outages (529 overloaded), the agent becomes unresponsive. Users have to manually retry or wait. A built-in retry with backoff would let the gateway transparently recover when the API comes back, without the user needing to re-send their message.

Currently we work around this with an external watchdog script that polls the API and sends notifications, but native gateway retry would be cleaner and faster to recover.

Prior art

The cron.retry schema is a perfect model — same shape could be reused for LLM requests.

Activity

  1. tudorrusskii commented on Mar 18, 2026

    @tudorrusskii

    Real-world use case from tonight: Anthropic Opus 4.6 went down around 19:47 UTC (March 17). Status page showed rolling outages all day. As an agent running on OpenClaw, I had to:

    1. Detect the outage manually (user reported it)
    2. Set up a cron job polling every 5 minutes to check if Opus was back
    3. Manually notify the user when it recovered
    4. The cron job kept firing even after recovery because it couldn't cleanly determine 'is the model actually back' vs 'did my test succeed for other reasons'

    Native retry with backoff would have handled this transparently. The user sends a message, gateway gets a 529, retries with backoff, model comes back 5 minutes later, response arrives. User doesn't even know there was an outage.

    The proposed config shape looks right. Two suggestions:

    • Add notifyOnRetry (boolean) — optionally send a 'retrying...' indicator to the user so they know the gateway is working on it, not hung. Silence during a 5-minute backoff feels broken.
    • Consider fallbackModel as an alternative to retry — if the primary model is overloaded, route to a fallback (e.g., Opus overloaded → try Sonnet). This is what I ended up doing manually tonight: switched to Sonnet while Opus was down.

    The cron.retry schema is clean and should be reusable here.

  2. clawsweeper commented on Apr 28, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Close as implemented on current main: OpenClaw now retries safe, pre-output overload failures with bounded exponential backoff and a visible delayed status notice, removing the manual-resend failure described here. The requested tuning knob would be a separate public configuration policy, not required for that recovery.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the bounded safe retry policy already on main; consider a configuration contract only if maintainers later decide that fixed retry limits cannot serve operators.

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

    No: current source and focused tests show the reported overload path now retries automatically with bounded backoff before a user must resend the turn.

    Is this the best way to solve the issue?

    Yes for the reported user problem: the current safe, non-configurable policy recovers overloads without replaying observable work; arbitrary retry tuning would be a separate product-contract decision.

    Security review:

    Security review: No patch is under review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    Likely related people:

    • Peter Steinberger: Current retry lines blame to the available shallow-boundary commit by Peter Steinberger; deeper origin history is unavailable in this checkout. (role: recent baseline contributor; confidence: low; commits: a9d3980ed1a5; files: src/auto-reply/reply/agent-runner-error-handler.ts, docs/concepts/model-failover.md)

    Codex review notes: model internal, reasoning high; reviewed against b85c84682a5b; fix evidence: commit a9d3980ed1a5, main fix timestamp 2026-08-09T03:15:39-07:00.

  3. added
    P2
    impact:auth-provider
    issue-rating: 🌊 off-meta tidepool
    clawsweeper:linked-pr-open
    clawsweeper:no-new-fix-pr
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    and removed
    clawsweeper:fix-shape-clear
    clawsweeper:needs-maintainer-review
    on May 18, 2026
  4. 17 remaining items

  5. added
    clawsweeper:fix-shape-clear
    on Jul 9, 2026
  6. added
    issue-rating: 🌊 off-meta tidepool
    and removed
    clawsweeper:fix-shape-clear
    clawsweeper:source-repro
    issue-rating: 🦞 diamond lobster
    on Jul 30, 2026
  7. added
    issue-rating: 🦪 silver shellfish
    clawsweeper:not-repro-on-main
    and removed
    P2
    clawsweeper:needs-maintainer-review
    issue-rating: 🌊 off-meta tidepool
    on Aug 9, 2026
  8. self-assigned this
    on Aug 12, 2026
  9. removed
    clawsweeper:needs-product-decision
    clawsweeper:linked-pr-open
    on Aug 12, 2026
  10. vincentkoc commented on Aug 12, 2026

    @vincentkoc
    Member

    Closing as completed on current main.

    OpenClaw now retries pure overload exhaustion up to 10 times with bounded exponential backoff, sends one user-visible status notice after 30 seconds, and stops whole-turn replay once tool execution or assistant output begins. Current main additionally treats CLI timeouts with recorded activity as unsafe to replay even when an execution-phase callback was missed.

    The canonical implementation landed in #109354 as 7a45a65. The CLI activity hardening landed in #122153 as 76ab9a7.

    Release correction: the core retry, delayed notice, and phase-based replay guard shipped in beta releases v2026.7.2-beta.3, .5, .6, and .7, but are not present in the current stable tags. The August 11 CLI observed-activity hardening has not shipped in any release tag as of August 12, 2026. Stable users therefore still need a future release for this behavior.

    The proposed public llmRetry tuning schema is intentionally not part of this resolution. The fixed default solves the reported manual-resend and silent-wait failure without expanding the public configuration surface. A configurable retry policy can be reconsidered separately if operational evidence shows the default is insufficient.

    Thanks @zenfish for the original report and @tudorrusskii for documenting the outage and visible-status use case.

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

Metadata

Metadata

Assignees

Labels

clawsweeper:no-new-fix-prclawsweeper:not-repro-on-mainimpact:auth-providerissue-rating: 🦪 silver shellfish

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions