Skip to content

Codex Stop hook does not mark sessions ended #493

Closed

Description

@Rex57

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.

Activity

  1. rohitg00 commented on May 18, 2026

    @rohitg00
    Owner

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

  2. added a commit that references this issue on May 22, 2026
    3551241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions