feat: support preTool and postTool hooks to codex#860
Open
zchee wants to merge 1 commit intoentireio:mainfrom
Open
feat: support preTool and postTool hooks to codex#860zchee wants to merge 1 commit intoentireio:mainfrom
zchee wants to merge 1 commit intoentireio:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Codex hook surface area for the newly-supported PreToolUse / PostToolUse events (Codex CLI 0.118.0+), wiring them into the Codex agent’s hook installation and lifecycle parsing as no-op/pass-through hooks for future expansion.
Changes:
- Add
PostToolUseto Codex hook config types and supported hook names. - Treat
PreToolUseandPostToolUseas pass-through lifecycle hooks (no lifecycle event emitted). - Install/uninstall/manage
PreToolUseandPostToolUsehook entries in.codex/hooks.json, and update related tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/agent/codex/types.go | Extends Codex hooks.json schema types to include PostToolUse. |
| cmd/entire/cli/agent/codex/lifecycle.go | Registers post-tool-use hook name and treats pre/post tool hooks as pass-through. |
| cmd/entire/cli/agent/codex/lifecycle_test.go | Updates lifecycle tests to cover both pass-through hooks. |
| cmd/entire/cli/agent/codex/hooks.go | Updates hook install/uninstall + detection to include Pre/Post tool hooks. |
| cmd/entire/cli/agent/codex/hooks_test.go | Updates install-count expectations for newly installed hooks. |
Comments suppressed due to low confidence (1)
cmd/entire/cli/agent/codex/hooks_test.go:37
- These tests now expect 5 hooks to be installed, but they still only assert that session-start/user-prompt-submit/stop commands appear in hooks.json. Add assertions for the new PreToolUse/PostToolUse hook commands as well so the test will catch mismatched verb names or missing hook entries.
ag := &CodexAgent{}
count, err := ag.InstallHooks(context.Background(), false, false)
require.NoError(t, err)
require.Equal(t, 5, count) // SessionStart, UserPromptSubmit, Stop, PreToolUse, PostToolUse
// Verify hooks.json was created in the repo
hooksPath := filepath.Join(tempDir, ".codex", HooksFileName)
data, err := os.ReadFile(hooksPath)
require.NoError(t, err)
require.Contains(t, string(data), "entire hooks codex session-start")
require.Contains(t, string(data), "entire hooks codex user-prompt-submit")
require.Contains(t, string(data), "entire hooks codex stop")
Codex 0.118.0 has supported the `PreToolUse` and `PostToolUse` hooks. These hooks are not required for entire, however, they have been implemented as stubs for future additional hooks to the Codex.
9f4e7af to
c7153e6
Compare
gtrrz-victor
requested changes
Apr 7, 2026
| case HookNamePreToolUse: | ||
| // PreToolUse has no lifecycle significance — pass through | ||
| case HookNamePreToolUse, HookNamePostToolUse: | ||
| // Acknowledged hooks with no lifecycle action |
Contributor
There was a problem hiding this comment.
That's where the real PR meat starts. Happy for you to take over and add an implementation that I can review later on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex 0.118.0 has supported the
PreToolUseandPostToolUsehooks.These hooks are not required for "Entire" (such as the Gemini hook), however, they have been implemented as stubs for future additional hooks to the Codex.