openclaw - ✅(Solved) Fix LiveSessionModelSwitchError blocks fallback-driven cross-provider model changes [1 pull requests, 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#58600Fetched 2026-04-08 02:00:21
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
referenced ×3cross-referenced ×1

Error Message

Bug Description\n\nWhen a live session has a model fallback chain configured (e.g., anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash), and the primary provider (Anthropic) becomes unavailable mid-session, the gateway throws LiveSessionModelSwitchError and aborts the fallback attempt instead of allowing it to proceed.\n\n## Root Cause\n\nIn dist/auth-profiles-B5ypC5S-.js around line 169325, there is a check that fires on fallback-triggered model changes, treating them the same as user-initiated /model switches. This prevents the fallback chain from ever executing.\n\n## Expected Behavior\n\nFallback-driven model changes (triggered by provider unavailability) should bypass the LiveSessionModelSwitchError check. Only user-initiated mid-flight model switches should throw this error.\n\n## Actual Behavior\n\nWhen Anthropic goes down and the gateway tries to fall back to Google/Gemini, it throws LiveSessionModelSwitchError and the session fails entirely, with 0 tokens processed.\n\n## Workaround\n\nPatching the JS to wrap the check in if (false && ...) works locally but must be reapplied after every npm install -g openclaw.\n\n## Steps to Reproduce\n\n1. Configure a fallback chain: anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash\n2. Spawn a sub-agent session\n3. Simulate Anthropic unavailability (or trigger during actual outage)\n4. Observe: session fails with LiveSessionModelSwitchError, fallback never executes\n\n## Version\n\n2026.3.28\n\n## Impact\n\nHigh — during provider outages, all agent sessions fail even when fallback providers are configured and available. Defeats the purpose of fallback chains.

Root Cause

Bug Description\n\nWhen a live session has a model fallback chain configured (e.g., anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash), and the primary provider (Anthropic) becomes unavailable mid-session, the gateway throws LiveSessionModelSwitchError and aborts the fallback attempt instead of allowing it to proceed.\n\n## Root Cause\n\nIn dist/auth-profiles-B5ypC5S-.js around line 169325, there is a check that fires on fallback-triggered model changes, treating them the same as user-initiated /model switches. This prevents the fallback chain from ever executing.\n\n## Expected Behavior\n\nFallback-driven model changes (triggered by provider unavailability) should bypass the LiveSessionModelSwitchError check. Only user-initiated mid-flight model switches should throw this error.\n\n## Actual Behavior\n\nWhen Anthropic goes down and the gateway tries to fall back to Google/Gemini, it throws LiveSessionModelSwitchError and the session fails entirely, with 0 tokens processed.\n\n## Workaround\n\nPatching the JS to wrap the check in if (false && ...) works locally but must be reapplied after every npm install -g openclaw.\n\n## Steps to Reproduce\n\n1. Configure a fallback chain: anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash\n2. Spawn a sub-agent session\n3. Simulate Anthropic unavailability (or trigger during actual outage)\n4. Observe: session fails with LiveSessionModelSwitchError, fallback never executes\n\n## Version\n\n2026.3.28\n\n## Impact\n\nHigh — during provider outages, all agent sessions fail even when fallback providers are configured and available. Defeats the purpose of fallback chains.

Fix Action

Fix / Workaround

Bug Description\n\nWhen a live session has a model fallback chain configured (e.g., anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash), and the primary provider (Anthropic) becomes unavailable mid-session, the gateway throws LiveSessionModelSwitchError and aborts the fallback attempt instead of allowing it to proceed.\n\n## Root Cause\n\nIn dist/auth-profiles-B5ypC5S-.js around line 169325, there is a check that fires on fallback-triggered model changes, treating them the same as user-initiated /model switches. This prevents the fallback chain from ever executing.\n\n## Expected Behavior\n\nFallback-driven model changes (triggered by provider unavailability) should bypass the LiveSessionModelSwitchError check. Only user-initiated mid-flight model switches should throw this error.\n\n## Actual Behavior\n\nWhen Anthropic goes down and the gateway tries to fall back to Google/Gemini, it throws LiveSessionModelSwitchError and the session fails entirely, with 0 tokens processed.\n\n## Workaround\n\nPatching the JS to wrap the check in if (false && ...) works locally but must be reapplied after every npm install -g openclaw.\n\n## Steps to Reproduce\n\n1. Configure a fallback chain: anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash\n2. Spawn a sub-agent session\n3. Simulate Anthropic unavailability (or trigger during actual outage)\n4. Observe: session fails with LiveSessionModelSwitchError, fallback never executes\n\n## Version\n\n2026.3.28\n\n## Impact\n\nHigh — during provider outages, all agent sessions fail even when fallback providers are configured and available. Defeats the purpose of fallback chains.

PR fix notes

PR #58638: fix(runner): allow fallback-driven model changes in live sessions

Description (problem / solution / changelog)

Summary

Fixes #58600

When a live session's primary provider (e.g., Anthropic) becomes unavailable and the gateway attempts to fall back to an alternate provider (e.g., Google/Gemini), the fallback was being blocked by LiveSessionModelSwitchError.

Root Cause

In src/agents/pi-embedded-runner/run.ts, the persistedSelection branch (which fires after a failed/aborted attempt) was throwing LiveSessionModelSwitchError regardless of whether the current invocation was user-initiated or fallback-driven. It re-reads the session store to detect model changes, but was always blocking if a difference was detected — even when the run itself was triggered by the fallback chain.

Fix

Gate the persistedSelection check on params.authProfileIdSource === "user". When the current invocation is fallback-driven (authProfileIdSource is not "user"), skip throwing LiveSessionModelSwitchError so the fallback can proceed normally.

  • If authProfileIdSource === "user" → user-initiated session → block mid-turn model changes as before
  • Otherwise → fallback-driven invocation → allow the switch

Testing

  • Configure a fallback chain: anthropic/claude-sonnet-4-6google/gemini-2.5-flash
  • Trigger a session when the primary provider is unavailable
  • Confirm fallback succeeds without LiveSessionModelSwitchError
  • Confirm user-initiated /model switches still throw the error mid-turn

Changed files

  • src/agents/pi-embedded-runner/run.ts (modified, +18/-0)
RAW_BUFFERClick to expand / collapse

Bug Description\n\nWhen a live session has a model fallback chain configured (e.g., anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash), and the primary provider (Anthropic) becomes unavailable mid-session, the gateway throws LiveSessionModelSwitchError and aborts the fallback attempt instead of allowing it to proceed.\n\n## Root Cause\n\nIn dist/auth-profiles-B5ypC5S-.js around line 169325, there is a check that fires on fallback-triggered model changes, treating them the same as user-initiated /model switches. This prevents the fallback chain from ever executing.\n\n## Expected Behavior\n\nFallback-driven model changes (triggered by provider unavailability) should bypass the LiveSessionModelSwitchError check. Only user-initiated mid-flight model switches should throw this error.\n\n## Actual Behavior\n\nWhen Anthropic goes down and the gateway tries to fall back to Google/Gemini, it throws LiveSessionModelSwitchError and the session fails entirely, with 0 tokens processed.\n\n## Workaround\n\nPatching the JS to wrap the check in if (false && ...) works locally but must be reapplied after every npm install -g openclaw.\n\n## Steps to Reproduce\n\n1. Configure a fallback chain: anthropic/claude-sonnet-4-6 → google/gemini-2.5-flash\n2. Spawn a sub-agent session\n3. Simulate Anthropic unavailability (or trigger during actual outage)\n4. Observe: session fails with LiveSessionModelSwitchError, fallback never executes\n\n## Version\n\n2026.3.28\n\n## Impact\n\nHigh — during provider outages, all agent sessions fail even when fallback providers are configured and available. Defeats the purpose of fallback chains.

extent analysis

TL;DR

Modify the check in dist/auth-profiles-B5ypC5S-.js to distinguish between user-initiated and fallback-driven model changes to prevent the LiveSessionModelSwitchError.

Guidance

  • Identify the specific check in dist/auth-profiles-B5ypC5S-.js around line 169325 that is causing the issue and consider modifying it to bypass the LiveSessionModelSwitchError for fallback-driven model changes.
  • Verify that the fallback chain is correctly configured and that the secondary provider (e.g., Google/Gemini) is available and functioning.
  • Test the modified check by simulating an Anthropic outage and observing whether the session successfully falls back to the secondary provider.
  • Consider implementing a more robust solution that persists across npm install commands, rather than relying on a temporary patch.

Example

No code snippet is provided as the issue does not include the exact code that needs to be modified.

Notes

The provided workaround of patching the JS file is not a sustainable solution, as it must be reapplied after every npm install command. A more permanent fix is needed to address this issue.

Recommendation

Apply a workaround by modifying the check in dist/auth-profiles-B5ypC5S-.js to bypass the LiveSessionModelSwitchError for fallback-driven model changes, as this is the most direct way to address the issue in the short term. A more permanent solution should be explored to ensure the fix persists across npm install commands.

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