#Cron custom session

17 messages · Page 1 of 1 (latest)

cinder hatch
#

If I set session key for a cron and session = isolated, will future runs have access to the same session?

uneven sigilBOT
cloud blazeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

uneven sigilBOT
winged sorrelBOT
#

No, session=isolated does not give future runs the same conversation history.

  • isolated = fresh session per run
  • if you want reuse across runs, use --session session:<your-key>
  • current binds to whatever session was active when you created the job

So the rule of thumb is:

  • isolated → stateless/background job
  • session:daily-brief → persistent cron memory
  • current → keep using the session you were in when adding the cron

Docs:

#

If you want, I can also show the exact CLI examples for all 3.

cinder hatch
#

web ui doesn't allow me to remove session value, only isolated or main. can I just remove the line in cron/jobs.json

winged sorrelBOT
#

I wouldn’t remove it.

If the job is an agentTurn, missing sessionTarget gets normalized back to isolated. So deleting the line won’t give you a persistent shared session.

What you want is:

"sessionTarget": "session:my-custom-key"

Better option, use CLI:

openclaw cron edit <job-id> --session "session:my-custom-key"

If you do edit ~/.openclaw/cron/jobs.json manually, I’d do it with the gateway stopped first, otherwise it may get rewritten.

cinder hatch
#

so I'll just need to set sessionTarget, not sessionKey?

winged sorrelBOT
#

Yep, for custom persistent cron history, sessionTarget is the important one.

Use:

"sessionTarget": "session:my-custom-key"

That tells cron to run in the persistent session my-custom-key.

A few nuances:

  • sessionTarget controls how the cron run is routed
  • for session:..., the actual session key is derived from that value
  • sessionKey is not the field you need to switch this from isolated to persistent

So in your case:

#
  • isolated → fresh run every time
  • sessionTarget: "session:foo" → reuse foo across runs

If you’re hand-editing jobs.json, I’d set sessionTarget and leave sessionKey alone unless you already have a stale/conflicting one there. If it exists, best to keep it consistent.

Example:

{
  "sessionTarget": "session:daily-brief"
}

not:

#
{
  "sessionTarget": "isolated"
}

If you want, paste one cron entry and I’ll tell you the exact edit.

cinder hatch
#

{
"id": "fe5887aa-1642-4232-9975-6e37eddf5124",
"name": "<name>",
"description": "<desc>",
"enabled": true,
"createdAtMs": 1776118908759,
"updatedAtMs": 1776154380474,
"schedule": {
"kind": "cron",
"expr": "0 * * * *",
"tz": "<tz>"
},
"sessionTarget": "session:cron",
"wakeMode": "now",
"payload": {
"kind": "agentTurn",
"message": "<msg>",
"model": "anthropic/claude-sonnet-4-6",
"timeoutSeconds": 300
},
"delivery": {
"mode": "none",
"channel": "discord",
"to": "<user>",
"bestEffort": true
},
"state": {
"nextRunAtMs": 1776157226659,
"lastRunAtMs": 1776153626665,
"lastRunStatus": "ok",
"lastStatus": "ok",
"lastDurationMs": 32766,
"lastDeliveryStatus": "not-delivered",
"consecutiveErrors": 0,
"lastDelivered": false
},
"deleteAfterRun": false,
"agentId": "main"
}

looks good?

winged sorrelBOT
#

Yep, that looks right 👍

The important part is:

"sessionTarget": "session:cron"

That means future runs should reuse the same named session instead of getting a fresh isolated one.

Only small notes:

  • session:cron is pretty generic, so if you have multiple jobs later, they could accidentally share context. I’d use something more specific, like session:hourly-<name>.
  • delivery.mode: "none" means it will not send anything out. In that case, channel, to, and bestEffort are basically ignored, so you can remove them for cleanliness.
  • no sessionKey field needed for this setup.

So functionally: yes, good.

#

If you want, a cleaner version would be:

{
  "sessionTarget": "session:hourly-report",
  "wakeMode": "now",
  "payload": {
    "kind": "agentTurn",
    "message": "<msg>",
    "timeoutSeconds": 300
  },
  "delivery": {
    "mode": "none"
  }
}
#

Glad that helped! 🎉
If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution.
This helps Answer Overflow index the solution for future users.