Repository navigation
feat(hooks): add Codex deny-retry hook - #1550
BjornMelin wants to merge 4 commits into
Conversation
📊 Automated PR Analysis
SummaryAdds programmatic Codex CLI hook support using a deny-with-suggestion pattern, since Codex's PreToolUse hooks cannot apply updatedInput in-place. Includes Review Checklist
Linked issues: #1003 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
cb45305 to
7aa7352
Compare
|
|
7aa7352 to
38f8f13
Compare
There was a problem hiding this comment.
Pull request overview
Adds first-class OpenAI Codex CLI integration to RTK’s hooks layer, aligning Codex with existing agent hook support while documenting why Codex currently requires a deny-with-suggestion workflow instead of in-place rewrites.
Changes:
- Add
rtk hook codexhandler and wire it into the CLI subcommands. - Extend
rtk init --codexto install/manage Codexhooks.json+ enablefeatures.codex_hooks = truein Codexconfig.toml, plus show/uninstall enhancements. - Update hook documentation across repo to reflect Codex’s deny-with-suggestion behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds the hook codex subcommand and routes execution to the Codex hook handler. |
| src/hooks/init.rs | Implements Codex hooks.json + config.toml install/state display/uninstall logic; adds related tests. |
| src/hooks/hook_cmd.rs | Implements Codex PreToolUse hook processing and deny-with-suggestion response shape; adds tests. |
| src/hooks/constants.rs | Adds CONFIG_TOML constant for Codex config handling. |
| src/hooks/README.md | Updates hooks matrix and implementation notes to include Codex behavior. |
| hooks/codex/README.md | Documents Codex hook wiring and deny-with-suggestion behavior. |
| hooks/README.md | Updates global hook docs to describe Codex’s non-transparent rewrite approach. |
| docs/contributing/TECHNICAL.md | Updates contributor docs to reflect Codex hook support. |
| README.md | Updates user-facing overview and supported tools table for Codex hook behavior. |
|
Wouldn't his also work on the codex app, ie not codex CLI? |
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
|
@BjornMelin @aeppling waiting for this |
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
|
Hey @BjornMelin Thanks for addressing this. I'm aware of the codex CLI gap for the updatedInput that is not honored, thus being said the deny retry approach can be costly :
RTK want to be a LLM proxy, transparent and efficient, and for this we want to detach from context based actions for LLMs, to avoid polluting context + more precision and reliable because deterministic. This is not possible yet because not all CLI support hooks, but for Codex we seems close to be able to do this. Your PR is clean and thanks for this, it has a lot of clean part that could be favorized, the approach is what i want to discuss. You can refer to my review on #2033 about the codex CLI updatedInput problem. |
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
|
期待,非常期待,不用为此转cloude code上 |
|
Hey @BjornMelin , sorry for the wait, since #2033 is not responding, you're welcome to take it from here if reviews taken into account, deny retry is not a logic we want in RTK since it can really cost more than it saves, if you want to continue this, refer to the #2033 and my reviews here and here :) Thanks again for contributing, sadly other PR look stale since last review |
Adds `rtk hook codex` subcommand for Codex CLI PreToolUse hooks. Since Codex doesn't yet apply updatedInput, uses deny-with-suggestion to prompt the agent to rerun with the rtk-rewritten command. Based on rtk-ai#1550.
|
Thanks for this, and for the careful writeup of why deny-with-suggestion was the only working path when you opened it. Codex support landed in #3552 on 2026-09-13: it adds |

Summary
Adds official Codex CLI hook support for RTK.
rtk hook codexfor CodexPreToolUseJSONrtk init --codexto writehooks.jsonand enable[features].codex_hooks = trueupdatedInputCloses #1003.
Codex hook behavior
Codex currently parses
updatedInputinPreToolUsehook output but does not apply it in practice. This PR uses the working path instead:The installed
hooks.jsoncommand is portable:{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "rtk hook codex", "statusMessage": "Checking RTK rewrite" } ] } ] } }Validation
cargo fmt --allcargo test codex -- --nocapturecargo test --allcargo clippy --all-targetsHOME=$(mktemp -d) ./target/debug/rtk init -g --codexgit statusreturns Codex deny payload withRerun that as: rtk git statusgit status --short, surfacedRerun that as: rtk git status --short, then reran the RTK commandNotes
cargo clippy --all-targets -- -D warningsis not the current CI command and fails on existing baseline warnings unrelated to this change. The repository CI command,cargo clippy --all-targets, passes.