Skip to content

[Bug]: LiveSessionModelSwitchError defeats fallback chain during provider outages #58347

Closed

Description

@jw29247

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

When the primary model (e.g. Anthropic opus) is down and the fallback chain reaches a non-Anthropic last-resort model (e.g. z-ai/glm-5-turbo), the gateway fires LiveSessionModelSwitchError to switch back to the primary — which is still down. This creates a death loop where the last-resort fallback never gets to execute.

Steps to reproduce

live session model switch detected: openrouter/z-ai/glm-5-turbo -> anthropic/claude-opus-4-6 fires every time z-ai is reached. The authProfileOverride is also re-persisted to sessions.json after each fallback, making manual clearing temporary.

Expected behavior

live model switch should be suppressed when falling back during an outage. Version: 2026.3.28 (f9b1079).

Actual behavior

When the primary model (e.g. Anthropic opus) is down and the fallback chain reaches a non-Anthropic last-resort model (e.g. z-ai/glm-5-turbo), the gateway fires LiveSessionModelSwitchError to switch back to the primary — which is still down. This creates a death loop where the last-resort fallback never gets to execute.

OpenClaw version

2026.3.28 (f9b1079)

Operating system

Latest MacOS

Install method

NPM GLOBAL

Model

openrouter/z-ai/glm-5-turbo -> anthropic/claude-opus-4-6

Provider / routing chain

openrouter/z-ai/glm-5-turbo -> anthropic/claude-opus-4-6

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Activity

  1. added
    bug
    on Mar 31, 2026
  2. g00dluck commented on Mar 31, 2026

    @g00dluck

    Reproducing this exact issue — LiveSessionModelSwitchError blocking fallback on rate limit

    Environment: OpenClaw 2026.3.28, macOS, default model gpt-5.4 with fallback to claude-opus-4-6

    What happened:

    1. gpt-5.4 hit ChatGPT team plan rate limit (HTTP 429, ~75h cooldown)
    2. Fallback chain attempted claude-opus-4-6 as next candidate
    3. LiveSessionModelSwitchError rejected the Claude candidate with: "Live session model switch requested: openai-codex/gpt-5.4"
    4. Fallback cycled back to gpt-5.4 → 429 again → infinite loop
    5. WhatsApp session became completely unresponsive until manual model override

    Log pattern (repeating):

    model_fallback_decision: candidate_failed (gpt-5.3-codex → claude-opus-4-6)
      reason: "Live session model switch requested: openai-codex/gpt-5.4"
    model_fallback_decision: candidate_succeeded (gpt-5.4)  ← but this is the rate-limited model
    

    Impact: Complete loss of service on WhatsApp channel for hours. Only resolved by manually switching the session model.

    Expected: When the rate-limited model triggers a fallback, LiveSessionModelSwitch should not override the fallback chain. The fallback model should be allowed to serve the request.

  3. jsompis commented on Mar 31, 2026

    @jsompis

    +1
    info agent/embedded {"subsystem":"agent/embedded"} live session model switch detected before attempt for fc95b21e-7946-42e9-bb44-a73f4734fae7: openai-codex/gpt-5.4 -> anthropic/claude-sonnet-4-6

  4. steipete commented on Apr 4, 2026

    @steipete
    Contributor

    Covered by #60266 on current main.

    I also re-ran the live Z.AI fallback repro after that fix: the primary provider was forced to fail auth, the fallback switched to zai/glm-4.7, and the second leg succeeded instead of getting trapped in a live-switch loop.

    Relevant regression coverage is in:

    • src/agents/live-model-switch.test.ts
    • src/cron/isolated-agent/run.live-session-model-switch.test.ts
    • src/agents/model-fallback.test.ts
    • src/auto-reply/reply/agent-runner-execution.test.ts

    Closing as completed.

  5. xeonai44 commented on Apr 4, 2026

    @xeonai44

    I am seeing this issue with local models.
    I set gemma4:26b as primary....
    gateway starts
    fallback to another local model and loops...
    than cannot message anymore

  6. locked as resolved and limited conversation to collaborators on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions