Codex Stop hook does not mark sessions ended
Bug
Codex plugin sessions can stay active in the AgentMemory viewer after Codex stops.
Environment
- OS: Windows
- Node: v24.14.1
- agentmemory: 0.9.18
- Agent: Codex CLI plugin installed through
/plugin
Repro
- Start
agentmemory. - Start a Codex session with the AgentMemory plugin enabled.
- End the Codex session.
- Open the AgentMemory viewer.
Expected
The session should be marked ended automatically.
Actual
The session can remain active until manually ending it in the viewer.
Root cause
plugin/hooks/hooks.codex.json wires Codex Stop to plugin/scripts/stop.mjs. That script only calls /agentmemory/summarize; it does not call /agentmemory/session/end.
plugin/scripts/session-end.mjs already has session-end behavior, but Codex does not expose/use a separate SessionEnd hook in hooks.codex.json.
Suggested fix
Have the Stop hook end the session after best-effort summarize. This keeps existing summary behavior while closing the viewer session lifecycle for Codex.
Related: #308 covers broader abandoned-session recovery. This issue is the narrower Codex Stop-hook lifecycle path.
Re-opening — the Stop-hook chain shipped in v0.9.19 (#495) was reverted via #501 because Codex Stop fires before the conversation actually finishes, marking sessions completed too early. Separate SessionEnd surface is what we want here. Tracking for v0.9.20+.