Bug: LiveSessionModelSwitchError crashes all isolated cron sessions
Version
OpenClaw 2026.3.28 (f9b1079, latest on npm)
Description
All cron jobs with sessionTarget: "isolated" crash immediately with LiveSessionModelSwitchError. The error occurs regardless of model configuration, payload settings, or agent setup.
Error Pattern
LiveSessionModelSwitchError: Live session model switch requested: zai/glm-4.7
The "requested" model in the error message always matches the agent's configured primary model — no actual model switch is happening.
Affected Jobs
All jobs with sessionTarget: "isolated" fail. Jobs using other session targets (e.g., main with kind: "systemEvent") work fine.
| Job |
Agent |
Agent Primary |
Error Model |
Result |
| twitter-research |
scout |
glm-4.7 |
glm-4.7 |
crash (3.2s) |
| web-research |
scout |
glm-4.7 |
glm-4.7 |
crash (0.4s) |
| memory-consolidation |
archivist |
glm-4.7-flashx |
glm-4.7-flashx |
crash (6.9s) |
| morning-brief |
dora |
glm-5-turbo |
glm-5-turbo |
crash (1.9s) |
What We Tested (none fixed it)
- Removed
model from job payload → still crashes
- Set
model in payload to match agent primary exactly → still crashes
- Removed
lightContext, thinking, fallbacks from payload → still crashes
- Gateway restart (clean, single instance) → still crashes
- Deleted all stale session files for affected agents → still crashes
- Reset job state (removed cached sessionId, reset consecutiveErrors) → still crashes
- Verified single gateway process (found and killed duplicate) → still crashes
- All 6 model APIs respond correctly when tested directly
- All agent API keys are valid (unique per-agent keys)
- Provider configs are complete in each agent's
models.json
Source Code Analysis
Examined the bundled source in dist/auth-profiles-B5ypC5S-.js:
// These are the SAME function — both read from LIVE_MODEL_SELECTIONS Map
function resolveCurrentLiveSelection(sessionKey) {
const current = LIVE_MODEL_SELECTIONS.get(sessionKey);
return current ?? void 0;
}
function resolvePersistedLiveSelection(sessionKey) {
return resolveCurrentLiveSelection(sessionKey);
}
The check in agent-runner.runtime:
const nextSelection = resolvePersistedLiveSelection();
if (hasDifferentLiveSessionModelSelection(resolveCurrentLiveSelection(), nextSelection)) {
throw new LiveSessionModelSwitchError(nextSelection);
}
Since both functions are identical and called without arguments, both should return undefined → hasDifferentLiveSessionModelSelection(undefined, undefined) returns false → error should never trigger. Yet it does.
This suggests either:
- An async operation modifies
LIVE_MODEL_SELECTIONS between the two calls
- Or the
resolveModelSelectionForSession() call earlier in the run sets a selection that conflicts with itself
- Or the functions are being called WITH different session keys in the actual runtime (the minified code may behave differently than the source suggests)
Reproduction
- Create a cron job with
sessionTarget: "isolated" and payload.kind: "agentTurn"
- Manually trigger it: via the cron API/tool
- Observe immediate crash with
LiveSessionModelSwitchError
Environment
- OS: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2, x64)
- Node: v22.22.1
- Agents: 6 configured agents (main/dora, scout, forge, archivist, watchman, rainmaker) with per-agent API keys and models
- Global default model:
zai/glm-5-turbo
- Provider: ZAI (first-party, 6 models registered)
Workaround
Disable all isolated cron jobs and run them manually from an interactive session when needed.
Bug: LiveSessionModelSwitchError crashes all isolated cron sessions
Version
OpenClaw
2026.3.28(f9b1079, latest on npm)Description
All cron jobs with
sessionTarget: "isolated"crash immediately withLiveSessionModelSwitchError. The error occurs regardless of model configuration, payload settings, or agent setup.Error Pattern
The "requested" model in the error message always matches the agent's configured primary model — no actual model switch is happening.
Affected Jobs
All jobs with
sessionTarget: "isolated"fail. Jobs using other session targets (e.g.,mainwithkind: "systemEvent") work fine.What We Tested (none fixed it)
modelfrom job payload → still crashesmodelin payload to match agent primary exactly → still crasheslightContext,thinking,fallbacksfrom payload → still crashesmodels.jsonSource Code Analysis
Examined the bundled source in
dist/auth-profiles-B5ypC5S-.js:The check in
agent-runner.runtime:Since both functions are identical and called without arguments, both should return
undefined→hasDifferentLiveSessionModelSelection(undefined, undefined)returnsfalse→ error should never trigger. Yet it does.This suggests either:
LIVE_MODEL_SELECTIONSbetween the two callsresolveModelSelectionForSession()call earlier in the run sets a selection that conflicts with itselfReproduction
sessionTarget: "isolated"andpayload.kind: "agentTurn"LiveSessionModelSwitchErrorEnvironment
zai/glm-5-turboWorkaround
Disable all isolated cron jobs and run them manually from an interactive session when needed.