Skip to content

[Bug]: Model fallback does not actually execute after rate_limit when session is pinned to primary model #56958

Description

@Xai17

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When the primary model hits 429 rate_limit_error, OpenClaw correctly decides to use the configured fallback model, but the active session’s persisted/live model selection switches the run back to the original primary model before the fallback attempt executes.

As a result, the session keeps retrying the rate-limited primary model and never actually runs the fallback model until I manually switch models.

Steps to reproduce

  1. Configure:

    • agents.defaults.model.primary = anthropic/claude-sonnet-4-6
    • agents.defaults.model.fallbacks = ["openai-codex/gpt-5.4"]
  2. Start a session that is actively using Sonnet, so the session is effectively pinned to Sonnet as its live/persisted model.

  3. Trigger a 429 rate_limit_error on Sonnet.

  4. Observe that OpenClaw makes a fallback decision for Codex:

    • failoverReason: "rate_limit"
    • decision: "fallback_model"
    • nextCandidateProvider: "openai-codex"
    • nextCandidateModel: "gpt-5.4"
  5. Observe that before the fallback attempt executes, the live session model selection switches execution back to Sonnet:

    • live session model switch detected before attempt for <sessionId>: openai-codex/gpt-5.4 -> anthropic/claude-sonnet-4-6
  6. The session then keeps retrying Sonnet instead of actually executing Codex, until I manually switch the session model.After a failover-worthy error such as 429 rate_limit_error, OpenClaw should actually execute the configured fallback model.

Expected behavior

After a failover-worthy error such as 429 rate_limit_error, OpenClaw should actually execute the configured fallback model.

A session’s persisted/live model selection should not override fallback in a way that traps the run on the failing primary model.

Actual behavior

Fallback is selected, but the session’s live/persisted model selection switches the run back to the primary model before execution.

This causes repeated retries on anthropic/claude-sonnet-4-6 and prevents the fallback model openai-codex/gpt-5.4 from actually running.

In practice, the session appears stuck until I manually switch models.

OpenClaw version

2026.3.28 Channel: stable OS: macOS 26.4 (arm64)

Operating system

macOS 26.4 (arm64)

Install method

npm global

Model

openai-codex/gpt-5.4 / anthropic/claude-sonnet-4.6 / anthropic/claude-opus-4.6

Provider / routing chain

claude-sonnet-4.6 -> openai-codex/gpt-5.4

Additional provider/model setup details

Relevant config:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-6",
        "fallbacks": ["openai-codex/gpt-5.4"]
      }
    }
  }
}

### Logs, screenshots, and evidence

```shell
• failoverReason: "rate_limit"
• decision: "fallback_model"
• nextCandidateProvider: "openai-codex"
• nextCandidateModel: "gpt-5.4"

But then:
live session model switch detected before attempt for <sessionId>: openai-codex/gpt-5.4 -> anthropic/claude-sonnet-4-6
Session transcript then showed repeated Sonnet errors like:

• provider: anthropic
• model: claude-sonnet-4-6
• stopReason: "error"
• errorMessage: 429 ... rate_limit_error ...

No successful fallback response from Codex occurred until I manually switched the session model.

This looks like a conflict between runtime failover selection and persisted/live session model selection.

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions