Check your version and execution host
You need an installed Codex CLI, Python 3, Git, and a trusted local test repository where you may add two configuration files. Start in a disposable project or your own worktree. Preserve any existing hook configuration rather than replacing it with this example.codex-cli 0.166.0-alpha.5.1 reports hooks as
stable and enabled. That is evidence about this build, not a minimum-version promise for every
installation. Follow the current OpenAI Hooks reference
for your host. The example below targets a locally executed Codex session; do not assume a local
script is deployed to a cloud execution environment.
Choose the mechanism
OpenAI documents
notify as an external notifier for turn completion; it is separate from
lifecycle hook configuration. See notification settings
and advanced notification configuration.
An alert to a human does not establish agent receipt.
Configure a scoped session-start hook
Codex supports project.codex/hooks.json and user ~/.codex/hooks.json, as well as inline TOML.
Matching sources accumulate. Project hooks require project trust; non-managed definitions need
review in /hooks. These rules and the event contracts are in the
official hook reference.
1. Add the small handler
Create.codex/hooks/ownership-context.py in your test repository:
AGENTS.md may be simpler.
2. Register the event
Merge this event into.codex/hooks.json:
commandWindows
configuration rather than copying POSIX shell syntax.
3. Test the handler before trusting it
From the repository root:4. Verify inside Codex
Start Codex in the test repository. Open/hooks, inspect the source and command, and trust only
the definition you reviewed. Start a fresh session after review to exercise startup. Ask:
resume. A listed hook establishes discovery; an executed hook and returned context
establish the next stages. If the host does not expose enough evidence, report that verification
as incomplete. Review later configuration changes before enabling them.
Keep hooks bounded
Start with one event, a short timeout and no network access. Treat event input as data: parse it rather than interpolating prompts or tool arguments into shell commands. Avoid logging full transcripts, prompts, credentials or environment variables. Before adding a blocking check, test its explicit allow, deny, malformed-output and timeout cases against the relevant event contract. A policy-looking script is not proof of enforcement. In particular, OpenAI warns that an MCP hook’s callback error or timeout can leave the operation unblocked. See managed-hook limitations. Keep tool matchers narrow and verify coverage for the tools your host actually uses. Do not copy Claude Code event names or decision JSON into Codex without checking the Codex reference.Where AMS fits
Use AMS when several independent tasks need a shared ownership decision or handoff. For a CLI workflow, first complete workspace setup, then have each task run this from its own working folder:enabled: true result. If disabled or invalid, leave AMS off.
In the enabled folder:
thread/inject_items appends context without starting a user turn. The installed CLI
labels app-server experimental. Do not present context injection, private host tools or an
AMS notification attempt as a stable hook-based wake-up guarantee.
Troubleshooting
For a native parent/worker workflow, see Codex subagents.
For reusable instructions, use Codex skills.
Source and local CLI contract review: 5 November 2026. The synthetic handler example was checked
locally; no live model session, external notification or account write was run for this guide.
Verify lifecycle execution in your own host before relying on it.