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.
Problem
When cron jobs or sub-agents spawn isolated sessions that fail, they leave behind "zombie" sessions that:
Current Gap
Existing tools:
sessions_list— View sessionssessions_send— Message sessionssessions_spawn— Create sessionssessions_history— View historyMissing:
sessions_kill— Terminate a specific sessionsessions_cleanup— Bulk kill orphansReal-World Impact
During automation testing, 23+ isolated cron sessions were spawned. The agent could see them via
sessions_listbut 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 terminateforce(optional): kill even if activesessions_cleanup:filter(optional): "orphaned", "inactive", "cron:*", etc.olderThan(optional): minutes since last activitydryRun(optional): preview without killingSecurity Considerations
Priority
Medium — Gateway restart works as workaround, but impacts resource management.