-
-
Notifications
You must be signed in to change notification settings - Fork 68.9k
[Feature]: Configurable idle session cleanup / TTL for cron, webhook, and subagent sessions #11643
Copy link
Copy link
Closed
Description
Problem
Long-running OpenClaw gateways accumulate many idle sessions from crons, webhooks (e.g., Alexa), and completed subagents. These sessions persist indefinitely with no way for the agent or user to clean them up.
In my setup after ~6 days of operation:
- 50+ sessions accumulated
- 8 stale Alexa/webhook sessions from days ago (never reused)
- 20+ old cron sessions (reused per-cron, but the list grows as crons are added/removed)
- Completed subagent sessions that served their purpose
There is no sessions_delete tool, no TTL config, and no auto-cleanup mechanism. The only way to clear them is a gateway restart.
Proposed Solution
- Session TTL config — e.g.,
agents.defaults.sessionTTL: "24h"to auto-delete sessions idle longer than the TTL - Per-session-type TTL — different TTLs for cron vs webhook vs subagent vs main sessions (main should never auto-delete)
sessions_deletetool — allow the agent to programmatically delete specific sessions by key- Cleanup on cron/webhook session reuse — when a cron fires and creates a new session, clean up the previous one
Related Issues
- [Bug]: Diagnostic session state Map grows unbounded without cleanup #5136 — Diagnostic session state Map grows unbounded (internal memory)
- [Bug]: Session manager cache checks TTL but never deletes expired entries #6761 — Session manager cache checks TTL but never deletes expired entries (cache layer)
- [Bug]: ABORT_MEMORY Map grows unbounded without cleanup #6629 — ABORT_MEMORY Map grows unbounded
Those address internal Maps/caches. This request is about the user/agent-facing session lifecycle.
Environment
- OpenClaw 2026.2.6
- 70+ cron jobs, webhook endpoints, frequent subagent spawns
- Gateway runs 24/7 for days/weeks without restart
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.