Skip to content

[codex] Avoid duplicate hooks.json discovery with profiles - #26418

Merged
abhinav-oai merged 2 commits into
mainfrom
abhinav/dedupe-profile-hooks-json
Jun 11, 2026
Merged

[codex] Avoid duplicate hooks.json discovery with profiles#26418
abhinav-oai merged 2 commits into
mainfrom
abhinav/dedupe-profile-hooks-json

Conversation

@abhinav-oai

@abhinav-oai abhinav-oai commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

V2 profiles add both config.toml and <profile>.config.toml to the config stack. Because both user layers resolve hook discovery to the same Codex home, Codex loaded the same hooks.json twice. This duplicated hook rows and caused each matching command to run twice.

Deduplicate JSON hook discovery by absolute config folder within each effective config stack. TOML hooks remain layer-specific, and multi-cwd hooks/list results remain independently resolved per cwd.

Reproduction

  1. Add config.toml and work.config.toml under $CODEX_HOME.
  2. Add one command hook to $CODEX_HOME/hooks.json.
  3. Run Codex with --profile work.
  4. Trigger the hook.

Before this change, one declaration creates two handlers. Afterward, it creates one.

Fixes #25645 and addresses the single-cwd duplication in #25437.

Validation

  • cargo nextest run -p codex-hooks
  • just fix -p codex-hooks
  • just fmt
  • just argument-comment-lint -p codex-hooks

@abhinav-oai
abhinav-oai marked this pull request as ready for review June 4, 2026 16:30
@abhinav-oai
abhinav-oai merged commit 0d8dee9 into main Jun 11, 2026
31 checks passed
@abhinav-oai
abhinav-oai deleted the abhinav/dedupe-profile-hooks-json branch June 11, 2026 22:25
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile config causes global hooks.json hooks to be discovered and executed twice

2 participants