Bug
Cron jobs with payload.model overrides (e.g., Haiku on a Sonnet-primary agent) fail with LiveSessionModelSwitchError when running as sessionTarget: "isolated".
Reproduction
- Configure an agent with primary model
anthropic/claude-sonnet-4-6
- Create an isolated cron job with
payload.model: "anthropic/claude-haiku-4-5"
- Wait for the job to fire
Expected: Job runs with Haiku as documented ("We recommend model overrides only for isolated jobs")
Actual: LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-sonnet-4-6
Root Cause
New in v2026.3.28: src/agents/live-model-switch.ts adds live model switch detection. In src/agents/pi-embedded-runner/run.ts:452-457, resolvePersistedLiveSelection() fires on every run loop iteration unconditionally — including for cron/isolated sessions.
For cron jobs: the run starts with the payload model override (Haiku), but resolvePersistedLiveSelection() reads the session entry which has no modelOverride set → falls back to resolveDefaultModelForAgent() → returns the agent's primary (Sonnet) → mismatch detected → error thrown.
The check doesn't distinguish between:
- Interactive session: user changed model in a live Discord conversation (intended use case)
- Cron job: payload has a different model than the agent default (should be allowed)
params.trigger === "cron" is available at the call site and could be used to skip the check.
Suggested Fix
In src/agents/pi-embedded-runner/run.ts, guard the live model switch check:
// Line ~451
if (params.trigger !== "cron") {
const nextSelection = resolvePersistedLiveSelection();
if (hasDifferentLiveSessionModelSelection(resolveCurrentLiveSelection(), nextSelection)) {
log.info(`live session model switch detected...`);
throw new LiveSessionModelSwitchError(nextSelection);
}
}
Same guard needed at the two other throw sites (~lines 598 and 613).
Impact
All cron jobs with model overrides on agents whose primary model differs. In our deployment: 46 jobs affected, forcing us to remove all Haiku overrides and run everything on Sonnet (~3x cost increase for lightweight maintenance jobs).
Environment
- OpenClaw 2026.3.28 (9ac1eba)
- macOS, Node 25.5.0
- Agents with
anthropic/claude-sonnet-4-6 primary model
- Cron jobs with
anthropic/claude-haiku-4-5 payload override
sessionTarget: "isolated" on all affected jobs
Bug
Cron jobs with
payload.modeloverrides (e.g., Haiku on a Sonnet-primary agent) fail withLiveSessionModelSwitchErrorwhen running assessionTarget: "isolated".Reproduction
anthropic/claude-sonnet-4-6payload.model: "anthropic/claude-haiku-4-5"Expected: Job runs with Haiku as documented ("We recommend model overrides only for isolated jobs")
Actual:
LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-sonnet-4-6Root Cause
New in v2026.3.28:
src/agents/live-model-switch.tsadds live model switch detection. Insrc/agents/pi-embedded-runner/run.ts:452-457,resolvePersistedLiveSelection()fires on every run loop iteration unconditionally — including for cron/isolated sessions.For cron jobs: the run starts with the payload model override (Haiku), but
resolvePersistedLiveSelection()reads the session entry which has nomodelOverrideset → falls back toresolveDefaultModelForAgent()→ returns the agent's primary (Sonnet) → mismatch detected → error thrown.The check doesn't distinguish between:
params.trigger === "cron"is available at the call site and could be used to skip the check.Suggested Fix
In
src/agents/pi-embedded-runner/run.ts, guard the live model switch check:Same guard needed at the two other throw sites (~lines 598 and 613).
Impact
All cron jobs with model overrides on agents whose primary model differs. In our deployment: 46 jobs affected, forcing us to remove all Haiku overrides and run everything on Sonnet (~3x cost increase for lightweight maintenance jobs).
Environment
anthropic/claude-sonnet-4-6primary modelanthropic/claude-haiku-4-5payload overridesessionTarget: "isolated"on all affected jobs