Skip to content

[Feature] session:end hook event for ephemeral webhook sessions #2725

Description

@mhit

Problem

Webhook-triggered agent sessions (via /hooks/agent or transform returning action: "agent") accumulate indefinitely in sessions.json. There is no built-in way to clean them up after the agent run completes.

This is problematic for use cases like:

  • Gmail webhook processing
  • Zoom chat notifications
  • Any high-frequency webhook integration

Current Workaround

Running a cron job to periodically delete old hook:* sessions:

clawdbot sessions --json | jq -r ".sessions[] | select(.key | startswith(\"hook:\")) | .key" | xargs -I{} clawdbot sessions delete {}

Proposed Solutions

Option 1: Implement session:end hook event

The docs list session:end under "Future Events" but it is not implemented. If implemented, users could create a hook like:

const handler: HookHandler = async (event) => {
  if (event.type !== "session" || event.action !== "end") return;
  if (!event.sessionKey?.startsWith("hook:")) return;
  // cleanup logic
};

Option 2: Add ephemeral option to webhook transform

Allow transforms to return ephemeral: true which automatically deletes the session after the agent run completes:

return {
  action: "agent",
  ephemeral: true,  // <-- auto-cleanup after run
  message: "...",
  sessionKey: "hook:gmail:..."
};

Environment

  • Clawdbot version: 2026.1.24-3
  • Platform: Linux (WSL2)

Would love to hear thoughts on the preferred approach!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions