iai-personal-memory-engine icon indicating copy to clipboard operation
iai-personal-memory-engine copied to clipboard

session_exit RPC handler exists but nothing ever sends the request

Open tom-shields-stitch opened this issue 3 months ago • 1 comments

What happens

core/__init__.py's dispatcher has a session_exit handler that calls run_light_consolidation (an FSRS decay/reinforcement tick over records touched in the last hour):

if method == "session_exit":
    ...
    result = run_light_consolidation(store, session_id=sid)

Nothing in the package ever sends a session_exit request — no hook, no CLI command, no wrapper code. It's the light, frequent counterpart to the nightly heavy pass, and per the Stop hook's own docstring ("Claude Code fires Stop after EVERY assistant response... this hook therefore does two cheap incremental things per response"), this is exactly the kind of per-response work that hook is already designed to carry — it just never got a step added for this specific RPC.

Effect

Verified against a live daemon: before wiring a caller in, select count(*) from events where kind='cls_consolidation_run' never showed a mode: "light" entry from any real session, regardless of how many sessions ran.

Fix

PR incoming: add cmd_session_exit to cli/_capture.py (mirrors the existing cmd_session_start), register it as iai-mcp session-exit --session-id ..., and call it as a third step from iai-mcp-session-capture.sh (the Stop hook, shared across Claude Code, Codex and Cursor), after the existing capture-turn-deferred catch-up and live-file rotation.

tom-shields-stitch avatar Aug 11 '26 09:08 tom-shields-stitch

Fixed in 3.0.2 — session_exit and its handler are removed as a dead path; nothing ever sent the request, so the target went rather than getting wired. Thanks for tracing it to the missing caller — you're credited in the 3.0.2 changelog.

CodeAbra avatar Aug 16 '26 21:08 CodeAbra