Codex CLI now supports 5 hooks after v0.117.0 — PreToolUse and PostToolUse just dropped
New beta hooks let developers intercept AI tool calls, enabling custom logic before and after execution.
The latest update to the Codex CLI, version 0.117.0, introduces a significant expansion of its extensibility framework with two new beta hooks: PreToolUse and PostToolUse. These additions complete a set of five core lifecycle hooks that developers can tap into, which now includes SessionStart, SessionStop, UserPromptSubmit, and the two new tool-focused events. This architecture allows for fine-grained interception and modification of an AI agent's behavior, particularly when it decides to execute an external function or API call (a "tool use"). The PreToolUse hook fires just before the agent executes a tool, letting developers inspect, validate, or even alter the arguments. The PostToolUse hook triggers after execution, providing access to the tool's results for processing, logging, or error handling.
In a practical demonstration of this new power, developer shanraisshan created an open-source wrapper that connects these hooks to an audio feedback system. The project, available on GitHub, plays distinct pre-recorded human sounds for each hook event—like a session starting, a prompt being submitted, or a tool being used. This creative example highlights the potential for building richer, more interactive, and audibly informative development and debugging environments. By providing these interception points, the Codex CLI empowers developers to build sophisticated monitoring, security, logging, and customization layers on top of AI agent workflows, moving beyond simple execution to fully observable and controllable systems.
- Codex CLI v0.117.0 adds PreToolUse & PostToolUse hooks, bringing total lifecycle hooks to five.
- Hooks allow developers to inject custom logic before/after an AI agent executes external tools or functions.
- A demo wrapper by shanraisshan uses the hooks to provide audible feedback for all agent actions.
Why It Matters
Enables advanced debugging, security, logging, and customization for AI agents, making them more observable and controllable in production.