agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Codex Stop hook does not mark sessions ended

Open Rex57 opened this issue 6 months ago • 1 comments

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

  1. Start agentmemory.
  2. Start a Codex session with the AgentMemory plugin enabled.
  3. End the Codex session.
  4. 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.

Rex57 avatar May 18 '26 08:05 Rex57

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+.

rohitg00 avatar May 18 '26 18:05 rohitg00