Skip to content

[Feature]: Configurable idle session cleanup / TTL for cron, webhook, and subagent sessions #11643

@peteropenclaw

Description

@peteropenclaw

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

  1. Session TTL config — e.g., agents.defaults.sessionTTL: "24h" to auto-delete sessions idle longer than the TTL
  2. Per-session-type TTL — different TTLs for cron vs webhook vs subagent vs main sessions (main should never auto-delete)
  3. sessions_delete tool — allow the agent to programmatically delete specific sessions by key
  4. Cleanup on cron/webhook session reuse — when a cron fires and creates a new session, clean up the previous one

Related Issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions