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!
Problem
Webhook-triggered agent sessions (via
/hooks/agentor transform returningaction: "agent") accumulate indefinitely insessions.json. There is no built-in way to clean them up after the agent run completes.This is problematic for use cases like:
Current Workaround
Running a cron job to periodically delete old
hook:*sessions:Proposed Solutions
Option 1: Implement
session:endhook eventThe docs list
session:endunder "Future Events" but it is not implemented. If implemented, users could create a hook like:Option 2: Add
ephemeraloption to webhook transformAllow transforms to return
ephemeral: truewhich automatically deletes the session after the agent run completes:Environment
Would love to hear thoughts on the preferred approach!