openclaw - ✅(Solved) Fix Isolated cron jobs fail with LiveSessionModelSwitchError when payload model differs from agent default [1 pull requests, 3 comments, 4 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#59657Fetched 2026-04-08 02:42:03
View on GitHub
Comments
3
Participants
4
Timeline
6
Reactions
0
Timeline (top)
commented ×3closed ×1cross-referenced ×1locked ×1

Isolated cron jobs (sessionTarget: "isolated") fail with LiveSessionModelSwitchError when the job payload specifies a different model than the agent's default model.

Error Message

LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6

Root Cause

In auth-profiles-*.js (~line 169324), before each attempt:

const nextSelection = resolvePersistedLiveSelection();
if (hasDifferentLiveSessionModelSelection(resolveCurrentLiveSelection(), nextSelection)) {
    throw new LiveSessionModelSwitchError(nextSelection);
}

isExpectedNonErrorLaneFailure() correctly identifies this as non-fatal (~line 138708), but entry.reject(err) still propagates the rejection to the cron runner, which records it as a job error.

Fix Action

Workaround

Set the cron job's model to match the agent's default model, or omit the model override.

PR fix notes

PR #59893: fix(cron): unwrap FailoverError to detect LiveSessionModelSwitchError in retry loop

Description (problem / solution / changelog)

When a cron job specifies a model override and only one fallback candidate is configured, the model-switch retry loop silently fails to fire. The cron runner catches LiveSessionModelSwitchError by instanceof to trigger retries (#57206), but since #58466 runWithModelFallback wraps that error into a FailoverError before re-throwing via throwFallbackFailureSummary. The instanceof check returns false, the catch falls through, and the job crashes instead of retrying with the requested model.

The root cause is a conflict between two fixes: the cron retry loop (commit 10ac6ead6b) expects a raw LiveSessionModelSwitchError, while the fallback-chain fix (#58466) converts it to FailoverError to prevent infinite retry loops inside runWithModelFallback. Both are correct in isolation — they just don't compose.

Fix: preserve the original LiveSessionModelSwitchError as cause on the FailoverError wrapper (model-fallback.ts), and teach the cron retry loop to unwrap it (run.ts). This keeps the fallback chain working as intended while letting the outer cron loop detect and retry model switches.

Changes:

  • model-fallback.ts: pass cause: err when wrapping LiveSessionModelSwitchError into FailoverError
  • cron/isolated-agent/run.ts: check both err instanceof LiveSessionModelSwitchError and err.cause instanceof LiveSessionModelSwitchError
  • run.live-session-model-switch.test.ts: new test for the wrapped-error retry path

Testing:

$ npx vitest run --config vitest.unit.config.ts src/cron/isolated-agent/run
✓ 10 test files | 49 tests passed

$ npx tsgo --noEmit  # only pre-existing errors (msteams SDK, pi-coding-agent)
$ npx oxlint src/agents/model-fallback.ts src/cron/isolated-agent/run.ts
Found 0 warnings and 0 errors.

Fixes #59657 Refs #57112

Changed files

  • src/agents/model-fallback.ts (modified, +1/-0)
  • src/auto-reply/reply/agent-runner-execution.ts (modified, +16/-9)
  • src/cron/isolated-agent/run.live-session-model-switch.test.ts (modified, +40/-0)
  • src/cron/isolated-agent/run.ts (modified, +16/-7)

Code Example

openclaw cron add --name "Test" --cron "30 * * * *" \
  --agent investor --session isolated \
  --model anthropic/claude-sonnet-4-5 \
  --message "Run a shell command"

---

LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6

---

const nextSelection = resolvePersistedLiveSelection();
if (hasDifferentLiveSessionModelSelection(resolveCurrentLiveSelection(), nextSelection)) {
    throw new LiveSessionModelSwitchError(nextSelection);
}
RAW_BUFFERClick to expand / collapse

Description

Isolated cron jobs (sessionTarget: "isolated") fail with LiveSessionModelSwitchError when the job payload specifies a different model than the agent's default model.

Steps to Reproduce

  1. Agent has default model anthropic/claude-opus-4-6
  2. Create an isolated cron job with a different model:
openclaw cron add --name "Test" --cron "30 * * * *" \
  --agent investor --session isolated \
  --model anthropic/claude-sonnet-4-5 \
  --message "Run a shell command"
  1. Job fails immediately:
LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-opus-4-6

Expected Behavior

Isolated cron jobs should use the model specified in the payload without conflicting with the agent's default model. The docs state:

Isolated jobs (agentTurn) can override the model and thinking level.

Actual Behavior

resolveLiveSessionModelSelection() reads the agent's default model, detects a mismatch with the cron payload model, and throws LiveSessionModelSwitchError. While this error is handled inside runAgentTurnWithFallback (caught + retry with switched model), the cron runner's command queue rejects the promise before the retry logic can execute.

Root Cause Analysis

In auth-profiles-*.js (~line 169324), before each attempt:

const nextSelection = resolvePersistedLiveSelection();
if (hasDifferentLiveSessionModelSelection(resolveCurrentLiveSelection(), nextSelection)) {
    throw new LiveSessionModelSwitchError(nextSelection);
}

isExpectedNonErrorLaneFailure() correctly identifies this as non-fatal (~line 138708), but entry.reject(err) still propagates the rejection to the cron runner, which records it as a job error.

Workaround

Set the cron job's model to match the agent's default model, or omit the model override.

Environment

  • OpenClaw: 2026.3.28 (f9b1079)
  • OS: macOS arm64
  • Node: v25.6.0

extent analysis

TL;DR

To fix the issue, update the cron job to either match the agent's default model or remove the model override, allowing isolated jobs to run without conflicting model specifications.

Guidance

  • Review the agent's default model and update the cron job's model to match, if necessary, to prevent LiveSessionModelSwitchError.
  • Consider removing the model override from the cron job payload to use the agent's default model, as a temporary workaround.
  • Verify that the resolveLiveSessionModelSelection() function is correctly handling model overrides for isolated cron jobs.
  • Check the OpenClaw documentation for any updates or changes to model override behavior in isolated cron jobs.

Example

No code snippet is provided, as the issue is more related to configuration and workflow rather than a specific code fix.

Notes

The current implementation of resolveLiveSessionModelSelection() and the handling of LiveSessionModelSwitchError in runAgentTurnWithFallback may need to be revisited to correctly support model overrides in isolated cron jobs.

Recommendation

Apply workaround: Update the cron job's model to match the agent's default model or remove the model override, as this is a more immediate solution to the issue, and the root cause analysis suggests a potential flaw in the current implementation of model override 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…

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 - ✅(Solved) Fix Isolated cron jobs fail with LiveSessionModelSwitchError when payload model differs from agent default [1 pull requests, 3 comments, 4 participants]