openclaw - 💡(How to fix) Fix [Bug]: LiveSessionModelSwitchError double-fires after model correction due to stale baseline comparison [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#59295Fetched 2026-04-08 02:26:20
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When the effective default model changes between sessions (e.g. after a config update or fallback rotation), LiveSessionModelSwitchError fires correctly on the first request but then fires again on the immediate retry even after the model has been corrected. The detection logic compares the current model against a stale snapshot taken at session load rather than the live default, causing a second redundant error within milliseconds of the first.

Error Message

2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=main durationMs=857 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6" 2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=858 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6" 2026-04-01T16:23:02.546-04:00 [diagnostic] lane task interrupted: lane=main durationMs=189 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6" 2026-04-01T16:23:02.547-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=190 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"

Root Cause

  1. Configure an agent with model A as default.
  2. Start a session; the session loads and snapshots model A as the baseline.
  3. Change the default model to model B (e.g. via config update or fallback rotation).
  4. Send a message. LiveSessionModelSwitchError fires correctly (model A != model B).
  5. The session corrects to model B.
  6. Send another message (or observe the retry loop). LiveSessionModelSwitchError fires again because the stale snapshot still holds model A.

Code Example

2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=main durationMs=857 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=858 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.546-04:00 [diagnostic] lane task interrupted: lane=main durationMs=189 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.547-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=190 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When the effective default model changes between sessions (e.g. after a config update or fallback rotation), LiveSessionModelSwitchError fires correctly on the first request but then fires again on the immediate retry even after the model has been corrected. The detection logic compares the current model against a stale snapshot taken at session load rather than the live default, causing a second redundant error within milliseconds of the first.

Steps to reproduce

  1. Configure an agent with model A as default.
  2. Start a session; the session loads and snapshots model A as the baseline.
  3. Change the default model to model B (e.g. via config update or fallback rotation).
  4. Send a message. LiveSessionModelSwitchError fires correctly (model A != model B).
  5. The session corrects to model B.
  6. Send another message (or observe the retry loop). LiveSessionModelSwitchError fires again because the stale snapshot still holds model A.

Expected behavior

After the session corrects its model to match the live default, subsequent requests should not trigger LiveSessionModelSwitchError. The comparison baseline should reflect the current default, not the original load-time snapshot.

Actual behavior

The error fires in pairs on the same lane within milliseconds. 587 instances observed in a single day's log.

Evidence from gateway log:

2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=main durationMs=857 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.350-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=858 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.546-04:00 [diagnostic] lane task interrupted: lane=main durationMs=189 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"
2026-04-01T16:23:02.547-04:00 [diagnostic] lane task interrupted: lane=session:agent:brianle:telegram:brianle:direct:2027045491:thread:2027045491:68863:heartbeat durationMs=190 reason="LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6"

Pattern repeats across multiple sessions and lanes (14:34, 14:35, 16:20, 16:23, 16:41, etc.) with the same double-fire within 200ms.

OpenClaw version

v2026.4.1

Operating system

macOS 15.4 (arm64)

Install method

npm global

Model

anthropic/claude-opus-4-6 (with prior sessions carrying stale openai-codex/gpt-5.4 overrides)

Provider / routing chain

openclaw -> anthropic

Additional provider/model setup details

The stale model overrides originated from a previous default model configuration. Sessions created under the old default retain the old model string in their JSONL state, triggering the mismatch on every subsequent load even though the live default has changed.

Logs, screenshots, and evidence

587 LiveSessionModelSwitchError instances in a single day's gateway log, consistently firing in pairs on the same session lane within 200ms. Log excerpts above.

Impact and severity

  • Affected: All sessions with a model mismatch between their stored state and the current default
  • Severity: Medium (causes noisy error output, disrupts lane routing, but does not block message delivery)
  • Frequency: Every request in affected sessions until full session reload, always double-fires
  • Consequence: Redundant error handling, unnecessary model switch attempts, log noise that obscures real issues

Additional information

Root cause traced via 5 Whys analysis: the detection logic takes a snapshot of the session model at load time and never refreshes it after a successful correction. The retry immediately re-triggers the same error because the snapshot is stale.

Two potential fixes:

  1. Preventive: Normalize the session model to the current live default at boot time, so stale overrides never enter the comparison path.
  2. Systemic: Update the baseline snapshot after a successful model correction, so subsequent comparisons use the corrected value.

Both approaches are complementary. Happy to pick this up and PR if wanted.

extent analysis

TL;DR

Update the detection logic to refresh the session model snapshot after a successful correction, ensuring subsequent comparisons use the corrected value.

Guidance

  • Identify the session model snapshot update logic and modify it to refresh the snapshot after a successful model correction.
  • Consider implementing a normalization step at session boot time to ensure the session model aligns with the current live default, preventing stale overrides from entering the comparison path.
  • Review the retry mechanism to determine if it can be optimized to avoid immediate re-triggering of the same error.
  • Verify the fix by monitoring the gateway log for LiveSessionModelSwitchError instances and confirming that the error no longer fires in pairs.

Example

// Pseudo-code example of updating the baseline snapshot after a successful model correction
if (modelCorrectionSuccessful) {
  updateSessionModelSnapshot(currentLiveDefaultModel);
}

Notes

The provided analysis suggests two potential fixes, and implementing both may be beneficial. However, updating the baseline snapshot after a successful model correction appears to be a more direct solution to the issue.

Recommendation

Apply the systemic fix by updating the baseline snapshot after a successful model correction, as it directly addresses the root cause of the issue and prevents redundant error handling.

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…

FAQ

Expected behavior

After the session corrects its model to match the live default, subsequent requests should not trigger LiveSessionModelSwitchError. The comparison baseline should reflect the current default, not the original load-time snapshot.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: LiveSessionModelSwitchError double-fires after model correction due to stale baseline comparison [1 participants]