Repository navigation
Description
Summary
When creating a cron job from a Discord/chat session with sessionTarget: "isolated", OpenClaw appears to persist the current chat sessionKey onto the job even when sessionKey was not explicitly provided.
That makes the job run against the chat-bound session instead of the expected isolated cron:<jobId> session, which can leak session/model state into a background script-style cron and cause runtime failures such as LiveSessionModelSwitchError.
Expected behavior
For cron jobs with:
sessionTarget: "isolated"- no explicit
sessionKeyprovided
OpenClaw should run the job in an isolated cron session (cron:<jobId>) and should not implicitly persist the creating chat/session sessionKey onto the job.
Actual behavior
Creating the cron job from a Discord session produced a stored job like this (abridged):
{
"sessionTarget": "isolated",
"payload": {
"kind": "agentTurn",
"model": "anthropic/claude-sonnet-4-6"
},
"sessionKey": "agent:cron-lite:discord:channel:1475102142951067682"
}Because sessionKey is present, the isolated runner uses that session key instead of cron:<jobId>.
Why this seems wrong
From the runtime code path, isolated cron execution uses roughly:
const baseSessionKey = params.sessionKey?.trim() || `cron:${params.job.id}`;So if a job gets a sessionKey injected during creation, it no longer behaves like a clean isolated cron run.
This is especially problematic for script-style jobs that:
- do not need chat history
- do not need current-session binding
- use
delivery.mode = "none" - are intended to run as clean background tasks
Observed failure mode
The affected job started failing with model-switch conflicts like:
LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-haiku-4-5
and earlier also:
LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-sonnet-4-6
This strongly suggests the cron run was inheriting/contending with model state from the chat-bound session.
Reproduction
- From a Discord/OpenClaw chat session, create a cron job using the cron tool/API with:
sessionTarget: "isolated"payload.kind: "agentTurn"- no explicit
sessionKey
- Inspect the stored/listed cron job.
- Observe that the job may contain the current chat
sessionKey. - Run the job and observe that it does not behave like a clean
cron:<jobId>isolated session.
Workaround
Manually clearing the stored sessionKey fixes the issue:
{
"patch": {
"sessionKey": null
}
}After patching sessionKey to null, the job no longer shows the chat-bound session key and behaves as expected.
Additional notes
This does not look like a problem with the isolated cron execution core itself.
The likely issue seems to be in the cron creation/request path, where the creating session's sessionKey is being implicitly forwarded/persisted onto the job even for sessionTarget: "isolated" jobs.
That may be reasonable for sessionTarget: "current", but it seems incorrect for plain isolated jobs.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
[-]Cron isolated jobs created from chat sessions may persist current sessionKey and lose true isolation[/-][+][Bug] Cron isolated jobs created from chat sessions may persist current sessionKey and lose true isolation[/+]jrsdhr commentedon Mar 31, 2026
Additional evidence from a second reproduction path (another Discord channel context):
New findings
This is not limited to one specific cron payload or delivery flow.
I reproduced the problem with minimal isolated jobs created from a Discord channel context:
A. Minimal job with Discord delivery
sessionTarget: isolatedanthropic/claude-opus-4-6LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-haiku-4-5B. Minimal job with
delivery.mode = nonesessionTarget: isolatedanthropic/claude-opus-4-6LiveSessionModelSwitchError: Live session model switch requested: anthropic/claude-haiku-4-5Important implication
This strongly suggests the bug is not only in Discord delivery / announce.
Even a minimal isolated job with
delivery.mode = nonecreated from the chat session is still inheriting / binding to the current Discord live session context.Stronger evidence: sessionKey injection still happens at creation time
When creating both minimal jobs from the Discord channel context, the returned job objects already contained:
sessionTarget: "isolated"agent:cron-lite:discord:channel:<channel-id>That means:
delivery.mode = noneisolatedis therefore not truly isolated for chat-created jobsWhy this matters
This explains why unrelated isolated cron jobs can fail before doing any real work:
Suggested clarification / fix
For jobs with:
sessionTarget = "isolated"sessionKeyOpenClaw should never automatically persist the current chat sessionKey into the job, regardless of delivery mode.
Instead it should always run on a clean cron session like:
cron:<jobId>Right now, chat-created isolated jobs appear to silently bind to the originating Discord session, which then causes cross-model live-session conflicts.
vincentkoc commentedon Apr 25, 2026
Closing this as a duplicate of #70619. Persisting the current session key into isolated cron jobs is part of the same isolation/state-contamination family.