openclaw - 💡(How to fix) Fix Bug: LiveSessionModelSwitchError triggers for isolated sessions on heartbeat/cron when defaults differ [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#58518Fetched 2026-04-08 02:01:44
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

When creating an isolated session via embedded workers (like cron or heartbeat), the session initially inherits the default primary model from agents.defaults.model.primary. However, when the heartbeat or cron payload explicitly requests a different model (e.g., ollama/qwen3:8b), the system triggers a LiveSessionModelSwitchError.

Error Message

Dynamically created isolated sessions (cron/heartbeat) should respect the model defined in their payload without triggering a session switch error against the system default primary model. The specified model in the payload should be treated as the valid target for that execution context. The only way to avoid the error currently is to force the agents.defaults.heartbeat.model (or the cron payload) to match the global agents.defaults.model.primary exactly.

Root Cause

Actual Behavior

The gateway logs spam LiveSessionModelSwitchError on every heartbeat or cron tick because the background session compares the requested payload model against the globally inherited primary model.

Fix Action

Workaround

The only way to avoid the error currently is to force the agents.defaults.heartbeat.model (or the cron payload) to match the global agents.defaults.model.primary exactly.

Code Example

[agent/embedded] live session model switch detected before attempt for 9b6e42a4: ollama/qwen3:8b -> openrouter/google/gemini-3.1-pro-preview
RAW_BUFFERClick to expand / collapse

Description

When creating an isolated session via embedded workers (like cron or heartbeat), the session initially inherits the default primary model from agents.defaults.model.primary. However, when the heartbeat or cron payload explicitly requests a different model (e.g., ollama/qwen3:8b), the system triggers a LiveSessionModelSwitchError.

Expected Behavior

Dynamically created isolated sessions (cron/heartbeat) should respect the model defined in their payload without triggering a session switch error against the system default primary model. The specified model in the payload should be treated as the valid target for that execution context.

Actual Behavior

The gateway logs spam LiveSessionModelSwitchError on every heartbeat or cron tick because the background session compares the requested payload model against the globally inherited primary model.

Log example:

[agent/embedded] live session model switch detected before attempt for 9b6e42a4: ollama/qwen3:8b -> openrouter/google/gemini-3.1-pro-preview

Workaround

The only way to avoid the error currently is to force the agents.defaults.heartbeat.model (or the cron payload) to match the global agents.defaults.model.primary exactly.

Suggested Fix

Update session validation for embedded runtime modes to prioritize the payload's requested model and bypass the strict switch comparison against the system-wide default primary model, unless a specific modelOverride exists in the session storage for that particular UUID.

extent analysis

TL;DR

Update the session validation logic to prioritize the payload's requested model for embedded runtime modes, bypassing the strict switch comparison against the system-wide default primary model.

Guidance

  • Identify the embedded runtime modes (e.g., cron, heartbeat) and modify the session validation logic to give precedence to the model specified in the payload.
  • Introduce a check for a modelOverride in the session storage for the specific UUID, and only perform the strict switch comparison if this override exists.
  • Review the logging mechanism to ensure that LiveSessionModelSwitchError is only triggered when a valid model switch is attempted, and not when the payload's requested model is used.
  • Verify that the agents.defaults.heartbeat.model and agents.defaults.model.primary settings are correctly configured and do not cause unintended model switches.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The suggested fix assumes that the embedded runtime modes can be reliably identified and that the payload's requested model can be trusted. Additional validation or error handling may be necessary to ensure the security and stability of the system.

Recommendation

Apply the suggested workaround by updating the session validation logic to prioritize the payload's requested model, as this approach directly addresses the reported issue and allows for more flexible model switching in embedded runtime modes.

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