Skip to content

Codex hooks never launch on Windows: the quoted command fails under cmd and PowerShell #307

Closed

Description

@blitzcrieg1

Summary

The Codex installer writes hook commands of the form "<python.exe>" "<agentmetry_ingest.py>" codex hook <Event>. On Windows, Codex reports each hook run as started and completed, yet nothing reaches ingest: no event, no 401, no spool entry. On the dogfood machine the last Codex event is from July, and three months of Codex use recorded nothing.

Evidence

Running the exact command from ~/.codex/hooks.json against a local listener:

How it is launched Exit Event sent
cmd /d /s /c <command> 1 no
powershell -Command <command> 1 no
powershell -Command & <command> 0 yes
The same command with the quotes removed, under cmd, PowerShell, or direct exec 0 yes

Under cmd the leading quoted token breaks cmd's quote stripping. Under PowerShell a command that starts with a quoted string is a string expression, not a call; the installer already guards against this for VS Code. Codex's hooks documentation does not say which shell it uses on Windows, but it supports a commandWindows override.

Separately confirmed: the sandbox account authenticates fine with the ingest-only token (#302, #303), and the recorder's access log shows no requests at all from these hook runs.

Fix

The Codex installer writes commandWindows with quotes removed, using the 8.3 short name for any path containing a space, and leaving a path that has no short name quoted rather than broken. Tests launch the generated command through cmd and PowerShell on Windows, including a path with a space, and fail with the old quoted form.

Related: #300 (approval applies to new conversations only), #302.

Activity

  1. blitzcrieg1 commented on Oct 22, 2026

    @blitzcrieg1
    OwnerAuthor

    Follow-up, now fixed on #308 (commit 3c93870). The first fix wrote Codex's commandWindows override, and Codex then ran no hook at all. Its review dialog hashes a hook without commandWindows while its runtime hashes it with it, so approvals never match: hooks/list (Codex app-server) reports the hooks as modified and skips them silently. Measured on Codex 0.163 with a throwaway CODEX_HOME: the same approvals read trusted once the override is removed. The installer now writes the unquoted form into command itself. Verified end to end: Codex CLI and the ChatGPT desktop app both deliver session, approval, tool-call and stop events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions