Repository navigation
fix(codex): hooks launch on Windows, whichever shell Codex uses - #308
Merged
Merged
Conversation
The Codex installer wrote `"<python.exe>" "<agentmetry_ingest.py>" codex hook <Event>`. Codex reported every hook run as completed and nothing reached ingest: under cmd /c the leading quoted token breaks cmd's quote stripping, under PowerShell a command starting with a quoted string is a string, and both exit 1 before Python starts. The dogfood machine's last Codex event was in July. (#307) Codex accepts a `commandWindows` override but does not say which shell it uses, so the installer now writes one that runs under cmd, PowerShell and direct execution: quotes removed, a path with a space replaced by its 8.3 short name, a path with no short name left quoted rather than broken. Tests launch the generated command through cmd and PowerShell, including a path with a space, and fail with the old form. docs/agent-coverage.md and the changelog also record that Codex applies hook approval to new conversations only (#300). README count 1870 -> 1881. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 21, 2026
…dows` The first commit on this branch put the unquoted Windows form in Codex's `commandWindows` override. On the dogfood machine Codex then ran no hook at all, approved or not, and said nothing. Its review dialog hashes a hook without `commandWindows`; its runtime hashes it with it. Every approval was stored against a hash the runtime never computes, so `hooks/list` reported all five hooks as `modified` and Codex skipped them. Measured on Codex 0.163 (the ChatGPT desktop app's engine) with a throwaway CODEX_HOME: the same stored approvals read `trusted` once the override is removed. With the unquoted form in `command` and one approval, a Codex CLI run and a ChatGPT desktop conversation both delivered session, approval, tool-call and stop events, the first Codex tool events since July. The installer now writes the unquoted form into `command` on Windows and never writes `commandWindows`; a reinstall drops one left by the earlier version. Three of the four new tests fail against the previous behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ook-command # Conflicts: # README.md
Merging master into this branch left two "### Fixed" headings in the same release. The entries are unchanged; the second heading is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ook-command # Conflicts: # CHANGELOG.md # README.md
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #307. Refs #300, #302.
What was wrong
The Codex installer wrote
"<python.exe>" "<agentmetry_ingest.py>" codex hook <Event>. On Windows, Codex reported every hook run as started and completed, but nothing reached ingest: no event, no 401, no spool. Run as written, the command exits 1 undercmd /c(the leading quoted token breaks cmd's quote stripping) and underpowershell -Command(a command that starts with a quoted string is a string, not a call). The installer already guards against the PowerShell case for VS Code. The dogfood machine's last Codex event was in July.What changed
windows_hook_command(command): removes the quotes; a path containing a space is replaced by its 8.3 short name (GetShortPathNameW); a path with no short name keeps its quotes, so the result is never worse than before.merge_codex_hooks(..., windows=None): on Windows each Agentmetry handler'scommandis the unquoted form. It does not use Codex'scommandWindowsoverride (see below). The command still containscodex hook, so idempotent reinstalls recognise our groups, and a reinstall drops acommandWindowsleft by the first commit.docs/agent-coverage.md: the Codex row notes the unquoted command, whycommandWindowsis avoided, and that/hooksapproval applies to conversations started afterwards.Tests (
tests/test_codex_windows_command.py, 11)commandfor every Codex event and nevercommandWindows; elsewhere the command keeps its quotes; reinstalling does not duplicate and drops an old override.cmdand PowerShell, with a plain path and with a path containing a space, and must write a marker with the right arguments. With the old quoted form both shell tests fail.Checks
Frozen files untouched; fingerprint
15846a0915769d4a. Ruff clean. Full suite: the three known local-only failures. README count 1870 to 1881.On the dogfood machine
Verified end to end on the dogfood machine. A Codex CLI run and a ChatGPT desktop conversation both delivered session, approval, tool-call and stop events, the first Codex tool events since July.
Why not
commandWindows(second commit)The first commit wrote Codex's
commandWindowsoverride, and Codex then ran no hook at all. Codex's review dialog hashes a hook withoutcommandWindowsand its runtime hashes it with it, so every approval is stored against a hash the runtime never computes:hooks/listreports the hooks asmodified, and they are skipped silently. Measured on Codex 0.163 with a throwawayCODEX_HOME: the same stored approvals readtrustedonce the override is removed.🤖 Generated with Claude Code