openclaw - 💡(How to fix) Fix Cron isolated sessions fail with LiveSessionModelSwitchError when payload model differs from agent default [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#57450Fetched 2026-04-08 01:49:31
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1locked ×1subscribed ×1

Error Message

LiveSessionModelSwitchError: Live session model switch requested: openai-codex/gpt-5.3-codex

Root Cause

In auth-profiles-*.js around line 161503, resolveLiveSessionModelSelection():

const defaultModelRef = agentId 
  ? resolveDefaultModelForAgent({ cfg, agentId }) 
  : { provider, model };
const entry = loadSessionStore(...)[sessionKey];
const provider = entry?.providerOverride?.trim() || defaultModelRef.provider;
const model = entry?.modelOverride?.trim() || defaultModelRef.model;

For a fresh cron isolated session, entry has no overrides, so it resolves to the agent default model rather than the cron payload model. The main run loop then detects a mismatch between the running model and this "persisted" selection, and throws.

The fix should likely seed the session store entry with the cron payload's model override before the run loop begins, or skip the live model switch check for isolated/ephemeral sessions that have an explicit model specified in the run parameters.

Fix Action

Workaround

Remove the model field from the cron payload or set it to match the agent's default model. This defeats the purpose of model overrides for cost optimization on lightweight tasks.

Code Example

LiveSessionModelSwitchError: Live session model switch requested: openai-codex/gpt-5.3-codex

---

const defaultModelRef = agentId 
  ? resolveDefaultModelForAgent({ cfg, agentId }) 
  : { provider, model };
const entry = loadSessionStore(...)[sessionKey];
const provider = entry?.providerOverride?.trim() || defaultModelRef.provider;
const model = entry?.modelOverride?.trim() || defaultModelRef.model;
RAW_BUFFERClick to expand / collapse

Bug Description

Cron jobs with sessionTarget: "isolated" that specify a model different from the agent's default model fail immediately with LiveSessionModelSwitchError. This is a regression introduced in 2026.3.28 — all prior versions allowed cron jobs to freely override the model.

Steps to Reproduce

  1. Configure an agent with a default model, e.g. openai-codex/gpt-5.3-codex for agent codex
  2. Create a cron job with sessionTarget: "isolated", agentId: "codex", and a different model in the payload, e.g. model: "openai-codex/gpt-5.2"
  3. Run the cron job (scheduled or manual trigger)

Expected Behavior

The cron job runs using the model specified in the payload (gpt-5.2), as it did in all versions prior to 2026.3.28.

Actual Behavior

The job fails within ~200ms with:

LiveSessionModelSwitchError: Live session model switch requested: openai-codex/gpt-5.3-codex

The error occurs because the run loop's live model switch detection (resolveLiveSessionModelSelection in auth-profiles-*.js) compares the currently running model (from the cron payload) against the agent's default model (resolved via resolveDefaultModelForAgent). Since the newly created isolated session has no providerOverride/modelOverride in the session store, it falls back to the agent default — which differs from the cron-specified model. This triggers a false positive "model switch detected" and throws LiveSessionModelSwitchError.

In the cron execution path, this error is not caught and retried the way it is in the interactive agent-runner loop (where the catch block at ~line 522 of agent-runner.runtime-*.js does continue with the new model). Instead, it propagates as an unhandled error and the job is marked as failed.

Root Cause Analysis

In auth-profiles-*.js around line 161503, resolveLiveSessionModelSelection():

const defaultModelRef = agentId 
  ? resolveDefaultModelForAgent({ cfg, agentId }) 
  : { provider, model };
const entry = loadSessionStore(...)[sessionKey];
const provider = entry?.providerOverride?.trim() || defaultModelRef.provider;
const model = entry?.modelOverride?.trim() || defaultModelRef.model;

For a fresh cron isolated session, entry has no overrides, so it resolves to the agent default model rather than the cron payload model. The main run loop then detects a mismatch between the running model and this "persisted" selection, and throws.

The fix should likely seed the session store entry with the cron payload's model override before the run loop begins, or skip the live model switch check for isolated/ephemeral sessions that have an explicit model specified in the run parameters.

Impact

  • All cron jobs using sessionTarget: "isolated" with a model override different from the agent's default are broken
  • Cross-provider overrides (e.g. agent default anthropic/claude-opus-4-6, cron model openai-codex/gpt-5.2) and same-provider overrides (e.g. gpt-5.3-codex vs gpt-5.2) are both affected
  • Jobs that happen to use the same model as the agent default still work (e.g. zombie-process-watchdog with gpt-5.3-codex on the codex agent)

Environment

  • OpenClaw version: 2026.3.28
  • Node.js: v25.8.1
  • Platform: macOS arm64

Workaround

Remove the model field from the cron payload or set it to match the agent's default model. This defeats the purpose of model overrides for cost optimization on lightweight tasks.

extent analysis

Fix Plan

To resolve the LiveSessionModelSwitchError issue, we need to seed the session store entry with the cron payload's model override before the run loop begins. Here are the steps:

  • Modify the resolveLiveSessionModelSelection function in auth-profiles-*.js to check if the session is an isolated cron job with a model override.
  • If it is, use the model override from the cron payload instead of the agent's default model.
  • Update the session store entry with the model override before the run loop begins.

Example code:

// auth-profiles-*.js
const resolveLiveSessionModelSelection = async ({ cfg, agentId, sessionKey, cronPayload }) => {
  const defaultModelRef = agentId 
    ? resolveDefaultModelForAgent({ cfg, agentId }) 
    : { provider, model };
  const entry = loadSessionStore(...)[sessionKey];

  // Check if it's an isolated cron job with a model override
  if (cronPayload && cronPayload.model) {
    // Use the model override from the cron payload
    const model = cronPayload.model;
    // Update the session store entry with the model override
    entry.modelOverride = model;
  } else {
    const provider = entry?.providerOverride?.trim() || defaultModelRef.provider;
    const model = entry?.modelOverride?.trim() || defaultModelRef.model;
  }
  // ...
}

Verification

To verify that the fix worked, create a new cron job with sessionTarget: "isolated" and a model override different from the agent's default model. Run the cron job and check that it completes successfully without throwing a LiveSessionModelSwitchError.

Extra Tips

  • Make sure to update the auth-profiles-*.js file with the modified resolveLiveSessionModelSelection function.
  • Test the fix with different scenarios, including cross-provider overrides and same-provider overrides.
  • Consider adding a retry mechanism for cron jobs that fail due to model switch errors, similar to the one in the interactive agent-runner loop.

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 - 💡(How to fix) Fix Cron isolated sessions fail with LiveSessionModelSwitchError when payload model differs from agent default [1 comments, 2 participants]