Codex shipped version 0.114.0 with a long-requested capability: hooks. The initial release is intentionally narrow—only two hook points are available right now, SessionStart and Stop—but even that small surface area maps neatly onto the two moments that matter most in an agent loop: when a session spins up (or resumes) and when an agent is about to yield.
The feature is described as experimental and early release, and it’s positioned as foundational: a programmable layer around the agent lifecycle that can be used to inject context, enforce workflow rules, and trigger automation at consistent points in the run. In other words, it’s a step toward combining deterministic automation (scripts, checks, conventions) with the more fluid behavior of an LLM-driven agent.
Enabling Codex hooks
Hooks are guarded behind a feature flag in this release. There are two supported paths:
- Enable via CLI:
codex features enable codex_hooks
- Enable via config:
- Add a features section with
codex_hooks = true
- Add a features section with
How hooks are defined
Hook definitions live in a hooks.json file, and Codex will look for it in either:
- a global .codex folder, or
- project/subfolder .codex folders
Each hook runs a command, with a timeout and a status message associated with it. The two currently available events are:
- SessionStart: fires when a session begins (or resumes)
- Stop: fires when the agent is about to finish its turn
Practical use cases for SessionStart and Stop
Even with only two events, the examples land squarely in day-to-day agent reliability work.
SessionStart hooks can be used to establish operating context early, such as:
- injecting project-specific instructions (for example: “use pnpm, not npm”)
- reading a handoff file or task brief so a session starts with the right framing
- running
git statusand passing along branch and working tree details
Stop hooks run right before the agent finishes a turn, and could be used to gate completion on checks or to generate structured output:
- blocking weak completions unless verification or tests are included
- generating a short handoff note, summary, or logs at the end of a turn
- running a targeted linter or lightweight code review flow on changed files
- running a test suite
There are also open questions. One reply asked how the output of a Stop hook is injected (for example, whether it becomes a normal user message), and the author noted they’d been writing results to a log and weren’t yet sure.
A small hook surface, a bigger automation story
The release is being framed as groundwork for “fast follows,” with multiple contributors involved in the PR. Community replies immediately pointed to broader agentic automation desires—more hook points (like pre/post tool use) and CLI loops/automation—suggesting hooks are likely to become a major extension point as Codex evolves.
Original source: https://x.com/LLMJunky/status/2031582374064951414