[Enhancement]: Install Codex's SessionEnd and Interrupt hooks
Affected area
CLI
Problem or opportunity
Codex now has SessionEnd (openai/codex#33895, merged 07-17) and Interrupt (openai/codex#40511, merged 08-25) hook events. Codex 0.154 lists both in its hook config. Relay installs neither:
- The generated Codex hook set (
crates/cli/src/agents/codex/mod.rs) has 9 events, withoutSessionEndorInterrupt. - The Codex adapter already maps
sessionEndto the agent end (crates/cli/src/agents/codex/adapter.rs:26), so half of it is there, but the hook is never installed. docs/nemo-relay-cli/codex.mdx:356says "The Codex plugin schema does not exposeSessionEnd", and the comment atcrates/cli/src/events/mod.rs:77says Codex has no reliableSessionEnd. Both are out of date.
Real run, Codex 0.154 app-server driven over JSON-RPC with a mock provider and both hooks installed: turn/interrupt ran Interrupt with the session and turn ids, and thread/archive ran SessionEnd with the transcript path. The interrupted turn sent no Stop.
So today:
- An interrupted Codex turn sends no
Stop, and Relay installs no hook that would see it, so itscodex-taskstays open until the idle timeout and closes as unfinished, not as interrupted. - The ATIF file is finalized when the task closes or at idle timeout, not when the session actually ends.
Proposed enhancement
- Add
SessionEndandInterruptto the generated Codex hooks. - Map
Interruptto a turn end with an interrupted status, the same way Claude'sStopFailurebecomes a failed turn end (crates/cli/src/agents/claude/adapter.rs:51). - Let
SessionEndfinalize the task and its ATIF, and update the docs and theevents/mod.rscomment.
Runtime contract and binding impact
CLI hook generation and the Codex adapter only. The hook digests and trust-hash tests change with the event list. No binding changes.
One catch I hit: Codex gives these two events a 1-second default timeout (3-second cap), while the transparent launch hashes every generated hook with a 600-second default (crates/cli/src/agents/codex/launch.rs:311). With that hash Codex reports both hooks as modified and skips them silently. The trust hash has to use the per-event timeout.
Alternatives considered
- Keep relying on
Stopand the idle timeout. It works, but interrupted turns and session ends show up late and unlabeled. - Install only
Interrupt.SessionEndmostly changes when ATIF is written, so it could wait.
Acceptance criteria
- The generated Codex hook config includes both events, and the trust tests cover them.
- An interrupted Codex turn closes as interrupted without waiting for the idle timeout.
- Ending a Codex session finalizes its ATIF.
- Docs no longer say Codex has no
SessionEnd.
Not checked: the interactive TUI, since I drove the app-server instead, and codex exec, where neither hook fired in my runs.
Two questions: should these be gated on a minimum Codex version above today's 0.143, and should Interrupt show as an error like StopFailure or as its own status?
I'd like to work on this. Can you assign it to me?
- Should these be gated on a minimum Codex version above today's 0.143
Yes. We can increase the floor
- should Interrupt show as an error like StopFailure or as its own status?
I think this is fine (showing as an error).