codemap icon indicating copy to clipboard operation
codemap copied to clipboard

codex: Stop hook fires per turn and kills the watch daemon after the first turn

Open JordanCoin opened this issue 1 month ago • 0 comments

Symptom

In a Codex session the codemap hooks degrade after the first turn: pre-edit and post-edit lose hub/importer context, session summaries report nothing, and the watch daemon is gone.

Cause

`codemap setup --agent codex` installs `codemap hook session-stop` on Codex's `Stop` event. In Codex, `Stop` fires at the end of every agent turn, not at session end. The session-stop handler releases the session lease and, with no leases left, stops the watch daemon. Only `session-start` restarts it, so the daemon is dead for the rest of the session.

Reproduce in a scratch repo with the hooks installed: one headless `codex exec` turn leaves zero leases and no daemon process.

Codex implements a `SessionEnd` hook event (root session only), which is what codemap already uses for Claude Code.

Fix

Install the Codex session-stop hook on `SessionEnd` instead of `Stop`, reconcile existing `Stop` entries on re-run of setup, and keep `doctor` in step.

JordanCoin avatar Oct 30 '26 19:10 JordanCoin