Skip to content

Feature Request: sessions_kill and sessions_cleanup tools #12297

@dTardis42

Description

@dTardis42

Problem

When cron jobs or sub-agents spawn isolated sessions that fail, they leave behind "zombie" sessions that:

  • Consume memory/context tokens
  • Clutter the session list
  • Cannot be cleaned up by the agent that created them

Current Gap

Existing tools:

  • sessions_list — View sessions
  • sessions_send — Message sessions
  • sessions_spawn — Create sessions
  • sessions_history — View history

Missing:

  • sessions_kill — Terminate a specific session
  • sessions_cleanup — Bulk kill orphans

Real-World Impact

During automation testing, 23+ isolated cron sessions were spawned. The agent could see them via sessions_list but had no mechanism to clean them up. Required a full gateway restart to clear ~250k tokens of wasted context.

Proposed Solution

sessions_kill:

  • sessionKey (required): session to terminate
  • force (optional): kill even if active

sessions_cleanup:

  • filter (optional): "orphaned", "inactive", "cron:*", etc.
  • olderThan (optional): minutes since last activity
  • dryRun (optional): preview without killing

Security Considerations

  • Agents should only kill their own sessions
  • Cannot kill system/core sessions
  • Bulk operations may need confirmation/elevation

Priority

Medium — Gateway restart works as workaround, but impacts resource management.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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