---
title: What hook.py does with it (to-do 37)
at: 2026-09-18T10:03:34+00:00
source: the agent
track: main
---
No payload adapter: the fields are Claude Code's, so `_ctx`, the write gate, the start block and the queue read a Codex event unchanged. The session's stem is the rollout file's (rollout-<time>-<id>), from transcript_path, as for Claude. Two additions in hook.py: `agent_of(payload)` tells Codex from Claude by the transcript path (rollout-… or /.codex/), recorded at SessionStart as the session's `agent` runtime key so the viewer can name it; and `_context` answers a Stop under Codex with `{"decision": "block", "reason": <the line>}`, because a Stop answered with hookSpecificOutput.additionalContext FAILS there — measured on 2026-09-18: "hook: Stop Failed", the turn ended, the model never saw it — while UserPromptSubmit, PostToolUse and SessionStart take additionalContext as Claude does. test_codex.py fires the measured payloads and checks all of it.
