openclaw - ✅(Solved) Fix LiveSessionModelSwitchError persists across isolated cron sessions [1 pull requests, 1 comments, 2 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#58585Fetched 2026-04-08 02:00:34
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1referenced ×1

Error Message

  1. The next run tries to use the primary model → gateway detects a model switch on the 'live session' → error

Fix Action

Workaround

  1. Set explicit model in cron payloads to match model.primary
  2. Remove model.fallbacks from the agent config
  3. If already poisoned: delete stale cron entries from sessions/sessions.json and restart gateway

PR fix notes

PR #58992: fix(cron): clear stale model state on new isolated sessions

Description (problem / solution / changelog)

Summary

  • Clear model, modelProvider, modelOverride, and providerOverride when creating new isolated cron sessions
  • Prevents stale model state from shadowing payload.model override and triggering LiveSessionModelSwitchError

Details

When resolveCronSession creates a new session for an isolated cron job, it spreads ...entry from the previous session to preserve per-session overrides. However, this also preserves stale model fields:

  • modelOverride/providerOverride from a previous /model command can shadow the cron payload's model override in resolveCronModelSelection
  • model/modelProvider from a previous fallback can trigger LiveSessionModelSwitchError when the next run tries to use the primary model

The fix adds these four fields to the isNewSession cleanup block, alongside the existing delivery context cleanup.

Fixes #58575 Fixes #58585

Test plan

  • Create cron job with --model haiku --session isolated; verify session uses haiku, not agent default
  • Trigger model fallback in one cron run; verify next run uses primary model without error
  • Verify non-isolated (reused) sessions still preserve model state correctly

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Changed files

  • src/cron/isolated-agent/delivery-target.ts (modified, +65/-35)
  • src/cron/isolated-agent/session.ts (modified, +8/-0)
RAW_BUFFERClick to expand / collapse

Bug

Isolated cron sessions (sessionTarget: "isolated") should start with a clean model state on every run, but they inherit stale model state from sessions.json. This causes LiveSessionModelSwitchError when:

  1. A cron run falls back to a different model (e.g., Gemini when Anthropic 429s)
  2. The fallback model gets cached in sessions/sessions.json for that cron's session key
  3. The next run tries to use the primary model → gateway detects a model switch on the 'live session' → error
  4. All subsequent runs for that job fail until sessions.json is manually cleaned

Additional detail

Isolated cron sessions also inherit subagents.model instead of model.primary from agent config when no explicit model is set in the cron payload. The model resolution docs say priority is: job payload override > hook defaults > agent config default. The agent config default should be model.primary, not subagents.model.

Expected behavior

  • Each isolated cron run should start with completely fresh model state
  • Model fallbacks in one run should not affect subsequent runs
  • Without explicit model override, isolated crons should use model.primary, not subagents.model

Environment

  • OpenClaw 2026.3.28 (f9b1079)
  • macOS, Node 24.14.0

Workaround

  1. Set explicit model in cron payloads to match model.primary
  2. Remove model.fallbacks from the agent config
  3. If already poisoned: delete stale cron entries from sessions/sessions.json and restart gateway

extent analysis

TL;DR

To fix the issue, set an explicit model in cron payloads to match model.primary or remove model.fallbacks from the agent config to prevent stale model state from being inherited by isolated cron sessions.

Guidance

  • Verify that the model field in the cron payload is set to the desired primary model to ensure each run starts with a clean state.
  • Check the agent config to confirm that model.primary is correctly set and that subagents.model is not being inherited by isolated cron sessions.
  • If issues persist, try removing model.fallbacks from the agent config to prevent model fallbacks from being cached.
  • To mitigate the issue, delete stale cron entries from sessions/sessions.json and restart the gateway.

Example

No code snippet is provided as the issue does not require a code change, but rather a configuration adjustment.

Notes

This solution assumes that the issue is caused by the inheritance of stale model state from sessions.json and that setting an explicit model in cron payloads or removing model.fallbacks from the agent config will resolve the issue.

Recommendation

Apply the workaround by setting an explicit model in cron payloads to match model.primary, as this is a straightforward and targeted solution that addresses the root cause of the issue.

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

  • Each isolated cron run should start with completely fresh model state
  • Model fallbacks in one run should not affect subsequent runs
  • Without explicit model override, isolated crons should use model.primary, not subagents.model

Still need to ship something?

×6

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

Back to top recommendations

TRENDING