-
-
Notifications
You must be signed in to change notification settings - Fork 68.9k
Cron sessions not closing after agent turn completes #12374
Copy link
Copy link
Closed
Description
Cron sessions not closing after agent turn completes
Summary:
Cron job sessions remain open indefinitely after the agent completes its turn, instead of auto-closing when the work is done.
Steps to reproduce:
- Configure a cron job with
agentTurnpayload - Let it run (agent completes turn successfully in ~1-2 seconds)
- Observe session remains open for 30+ minutes with no activity
Expected behavior:
Session should auto-close after the agent's turn completes.
Actual behavior:
Session stays open indefinitely until manually killed or health monitor detects inactivity.
Example:
{
"schedule": { "kind": "cron", "expr": "*/5 * * * *" },
"sessionTarget": "isolated",
"payload": {
"kind": "agentTurn",
"message": "Read HEARTBEAT.md if it exists..."
}
}Observed pattern:
- Gateway spawns cron session → agent turn executes
- Agent completes turn successfully (~1.3s runtime)
- Gateway writes final assistant message to JSONL
- Session should close but stays open
- Session sits idle for 30+ minutes (no new messages, no activity)
- Eventually killed by external health monitor
Impact:
- Resource leak (sessions accumulate over time)
- Requires external cleanup to prevent session buildup
- Affects all
agentTurncron jobs
OpenClaw version:
Commit: bc475f0 (backup-before-sync-20260208)
Workaround:
Add timeoutSeconds to payload forces session closure, but this is a hard timeout rather than proper cleanup.
Logs:
Session logs show clean completion (exit/finish message), but session lifecycle doesn't close the session file or remove from active sessions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.