Summary
Cron jobs configured with sessionTarget: "isolated" and deleteAfterRun: true are not being deleted after execution. Sessions accumulate in sessions.json, inherit context from previous runs, and eventually overflow with Context overflow: prompt too large for the model.
This breaks all cron-based automation: backups, health checks, scheduled tasks.
Environment
- OpenClaw version: 2026.4.12
- Platform: Linux x64
- Node: v24.14.0
Cron Configuration
All jobs configured with:
{
"sessionTarget": "isolated",
"deleteAfterRun": true
}
Example jobs (various intervals):
- Health check — every 6h
- Session cleanup — every 1d
- Skill updates — every 1d
- Daily backup — every 1d
Expected Behavior
With deleteAfterRun: true:
- Cron job creates an isolated session key
- Cron job executes its payload
- Session entry is removed from
sessions.json after execution
- No accumulation across runs
Actual Behavior (Bug)
- Cron job creates an isolated session key
- Cron job executes its payload
- Session entry remains in
sessions.json after execution
- Sessions accumulate over time
- Each cron run loads history from previous cron sessions
- Context grows until overflow:
Context overflow: prompt too large for the model
Evidence
Session Accumulation
From the agent's sessions.json, cron sessions persist and accumulate:
Total sessions: 10
Cron sessions (not being deleted):
agent:<agent-id>:cron:<uuid>:run:<uuid> (×6 entries)
Cron Job State
{
"lastRunStatus": "ok",
"lastStatus": "ok",
"lastDelivered": true,
"lastDeliveryStatus": "delivered",
"consecutiveErrors": 0
}
Jobs complete successfully — but sessions are never cleaned up.
Related Version Notes
2026.4.14
2026.4.12 (Current)
- No
sessionTarget: "ephemeral" support
deleteAfterRun: true for cron sessions is not working
Impact
- All cron automation broken
- Cron jobs fail repeatedly with context overflow
- Manual session cleanup required
- Cannot schedule reliable automated tasks
- Daily backups, health checks, and maintenance all failing
Workarounds
Manual Session Cleanup
# Remove cron sessions from sessions.json
python3 -c "
import json
sessions = json.load(open('sessions.json'))
sessions = {k: v for k, v in sessions.items() if 'cron:' not in k}
json.dump(sessions, open('sessions.json', 'w'), indent=2)
"
Periodic Reset
Running /reset on cron job sessions — temporary, not sustainable.
Additional Error
Gateway logs also show:
request handler failed: TypeError: Cannot read properties of undefined (reading 'startsWith')
This occurred when trying to manage cron jobs via CLI, suggesting broader cron system instability.
Recommendations
- Fix
deleteAfterRun: true for cron sessions — ensure sessions are removed after execution
- Backport
sessionTarget: "ephemeral" to 2026.4.12 — or provide it in a patch release
- Add automatic cron session cleanup — configurable retention for orphaned cron sessions
Summary
Cron jobs configured with
sessionTarget: "isolated"anddeleteAfterRun: trueare not being deleted after execution. Sessions accumulate insessions.json, inherit context from previous runs, and eventually overflow withContext overflow: prompt too large for the model.This breaks all cron-based automation: backups, health checks, scheduled tasks.
Environment
Cron Configuration
All jobs configured with:
{ "sessionTarget": "isolated", "deleteAfterRun": true }Example jobs (various intervals):
Expected Behavior
With
deleteAfterRun: true:sessions.jsonafter executionActual Behavior (Bug)
sessions.jsonafter executionEvidence
Session Accumulation
From the agent's
sessions.json, cron sessions persist and accumulate:Cron Job State
{ "lastRunStatus": "ok", "lastStatus": "ok", "lastDelivered": true, "lastDeliveryStatus": "delivered", "consecutiveErrors": 0 }Jobs complete successfully — but sessions are never cleaned up.
Related Version Notes
2026.4.14
sessionTarget: "ephemeral"which would prevent context loading for cron sessions2026.4.12 (Current)
sessionTarget: "ephemeral"supportdeleteAfterRun: truefor cron sessions is not workingImpact
Workarounds
Manual Session Cleanup
Periodic Reset
Running
/reseton cron job sessions — temporary, not sustainable.Additional Error
Gateway logs also show:
This occurred when trying to manage cron jobs via CLI, suggesting broader cron system instability.
Recommendations
deleteAfterRun: truefor cron sessions — ensure sessions are removed after executionsessionTarget: "ephemeral"to 2026.4.12 — or provide it in a patch release