Missing on_session_end hook — no cleanup on session end #3

Open
opened 2026-06-10 10:28:27 +00:00 by glow · 0 comments
Owner

Problem

The plugin registers three hooks (pre_llm_call, post_tool_call, on_session_start) but does not register on_session_end.

When a session ends (user closes chat, timeout, disconnect), the agenda state remains in Sibyl's state_documents table with status: "active". Next session start detects the stale state and logs "Active agenda detected on session start" but there's no way to distinguish a fresh continuation from stale garbage.

Suggested fix

Add an on_session_end hook that checks the agenda status. If the status is still "active" and the session ending is not a clean handoff (e.g. user disconnected), mark it as status: "paused" or clear it entirely.

A safer approach: only clear if the agenda's session_id matches the ending session, to avoid stealing an agenda from a concurrent session.

## Problem The plugin registers three hooks (`pre_llm_call`, `post_tool_call`, `on_session_start`) but does **not** register `on_session_end`. When a session ends (user closes chat, timeout, disconnect), the agenda state remains in Sibyl's `state_documents` table with `status: "active"`. Next session start detects the stale state and logs "Active agenda detected on session start" but there's no way to distinguish a fresh continuation from stale garbage. ## Suggested fix Add an `on_session_end` hook that checks the agenda status. If the status is still "active" and the session ending is not a clean handoff (e.g. user disconnected), mark it as `status: "paused"` or clear it entirely. A safer approach: only clear if the agenda's `session_id` matches the ending session, to avoid stealing an agenda from a concurrent session.
Sign in to join this conversation.
No labels
bug
feature
improvement
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
glow-all/agenda-plugin#3
No description provided.