openclaw - 💡(How to fix) Fix Subagent runs don't use model fallback chain on 429/rate-limit errors [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57900Fetched 2026-04-08 01:56:20
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Error Message

When a subagent is spawned via sessions_spawn, the configured fallback chain is not used when the primary model returns a 429 rate-limit error. The run fails with LiveSessionModelSwitchError instead of falling back. The main agent loop correctly catches LiveSessionModelSwitchError and continues with the next model. But subagent/embedded runs do not — the error propagates as fatal and the run dies.

Fix Action

Workaround

Manually re-spawning subagents with the next model in the chain on failure.

Code Example

if (err instanceof LiveSessionModelSwitchError) {
    params.followupRun.run.provider = err.provider;
    params.followupRun.run.model = err.model;
    continue; // Works for main agent, NOT for subagents
}
RAW_BUFFERClick to expand / collapse

Bug Description

When a subagent is spawned via sessions_spawn, the configured fallback chain is not used when the primary model returns a 429 rate-limit error. The run fails with LiveSessionModelSwitchError instead of falling back.

Expected Behavior

429 on primary → exhaust profile rotation → move to next model in fallbacks → continue until success or all fallbacks exhausted.

Actual Behavior

The main agent loop correctly catches LiveSessionModelSwitchError and continues with the next model. But subagent/embedded runs do not — the error propagates as fatal and the run dies.

Evidence from Source

agent-runner.runtime-*.js main loop:

if (err instanceof LiveSessionModelSwitchError) {
    params.followupRun.run.provider = err.provider;
    params.followupRun.run.model = err.model;
    continue; // Works for main agent, NOT for subagents
}

The embedded/subagent run path lacks this catch.

Environment

  • OpenClaw: 2026.3.28, Ubuntu Linux 6.17.0-19, Node v22.22.1

Workaround

Manually re-spawning subagents with the next model in the chain on failure.

Impact

High — free-tier OpenRouter models rate-limit frequently. Fallback config exists but is never exercised for subagent runs.

extent analysis

Fix Plan

To fix the issue, we need to add the missing error handling for LiveSessionModelSwitchError in the subagent/embedded run path.

Step-by-Step Solution:

  • Modify the agent-runner.runtime-*.js file to include the error handling for subagent runs.
  • Add a try-catch block around the subagent run code to catch LiveSessionModelSwitchError.
  • Update the subagent run code to continue with the next model in the fallback chain when a LiveSessionModelSwitchError occurs.

Example Code:

// Subagent run code
try {
    // Existing subagent run code
} catch (err) {
    if (err instanceof LiveSessionModelSwitchError) {
        params.followupRun.run.provider = err.provider;
        params.followupRun.run.model = err.model;
        continue; // Continue with the next model in the fallback chain
    } else {
        throw err; // Rethrow other errors
    }
}

Verification

To verify the fix, test the subagent run with a primary model that returns a 429 rate-limit error. The subagent should now correctly fall back to the next model in the chain and continue running.

Extra Tips

  • Make sure to update the agent-runner.runtime-*.js file in all relevant environments.
  • Consider adding logging to track when the fallback chain is used to help with debugging and monitoring.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING