Repository navigation
Speed up Windows Codex/Claude hooks without dropping events - #6402
Merged
Merged
Conversation
Windows runs managed hooks through a shell, and #6078 wrapped the launcher in `powershell -EncodedCommand` to survive spaces in profile paths. Combined with the inner PowerShell Invoke-WebRequest post, every hook spawned two PowerShell processes (~300ms startup each), so a hook took ~650ms+ and fired up to 6x per turn. Codex 0.140 renders that as lingering "Running <event> hook" rows. The earlier RC worked around it by deleting SessionStart/UserPromptSubmit/Stop, which loses lifecycle status fidelity. Keep all six Codex events and make them fast instead: - Codex runs hooks as `cmd.exe /C <command>` and forwards our string verbatim when it has no spaces/quotes, so emit the bare .cmd path for cmd-safe profiles (zero shell startup) and fall back to the encoded PowerShell launcher only for spaced/metachar paths (#6078 robustness). - Replace the inner PowerShell post with curl.exe (Windows 10 1803+), posting the same form fields as the POSIX hook and reading the raw payload from stdin via `--data-urlencode payload@-` so UTF-8 (e.g. CJK) survives without code-page translation. Result: the common Codex case is 0 PowerShell (~70-150ms vs ~650ms); spaced-path profiles drop to 1. Claude runs hooks through Git Bash, so its launcher must stay PowerShell-encoded (a bare path is what breaks it), but its inner post moves to curl.exe too, cutting Claude from two PowerShell startups to one. Validated against the real Codex 0.140 binary (interactive TUI + exec): all managed hooks fire, render briefly, and clear with no lingering rows; the listener receives every post in 1-6ms. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds a Windows curl-based hook POST command helper, switches the Windows managed hook scripts for Claude and Codex to use it, and expands Windows tests to cover command generation, direct ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nwparker
added a commit
that referenced
this pull request
Aug 20, 2026
…erpreter The Antigravity drift was invisible to per-agent tests. The shared builder took only `(source)` and could not add the extra form field Antigravity needs, so it forked a private copy of the then-correct PowerShell command (#2100); when the shared builder moved to curl (#6402) every caller was fixed for free and the copy silently was not. Assert the violated invariant across all ten batch-script agents at once, and generate under a mocked win32 platform so the POSIX CI legs guard it too. Verified to fail on the pre-fix script, naming the offending file.
Merged
9 tasks done
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…#6402) Windows runs managed hooks through a shell, and stablyai#6078 wrapped the launcher in `powershell -EncodedCommand` to survive spaces in profile paths. Combined with the inner PowerShell Invoke-WebRequest post, every hook spawned two PowerShell processes (~300ms startup each), so a hook took ~650ms+ and fired up to 6x per turn. Codex 0.140 renders that as lingering "Running <event> hook" rows. The earlier RC worked around it by deleting SessionStart/UserPromptSubmit/Stop, which loses lifecycle status fidelity. Keep all six Codex events and make them fast instead: - Codex runs hooks as `cmd.exe /C <command>` and forwards our string verbatim when it has no spaces/quotes, so emit the bare .cmd path for cmd-safe profiles (zero shell startup) and fall back to the encoded PowerShell launcher only for spaced/metachar paths (stablyai#6078 robustness). - Replace the inner PowerShell post with curl.exe (Windows 10 1803+), posting the same form fields as the POSIX hook and reading the raw payload from stdin via `--data-urlencode payload@-` so UTF-8 (e.g. CJK) survives without code-page translation. Result: the common Codex case is 0 PowerShell (~70-150ms vs ~650ms); spaced-path profiles drop to 1. Claude runs hooks through Git Bash, so its launcher must stay PowerShell-encoded (a bare path is what breaks it), but its inner post moves to curl.exe too, cutting Claude from two PowerShell startups to one. Validated against the real Codex 0.140 binary (interactive TUI + exec): all managed hooks fire, render briefly, and clear with no lingering rows; the listener receives every post in 1-6ms. Co-authored-by: Neil <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
Problem (regression)
On Windows, managed hooks run through a shell. #6078 wrapped the launcher in
powershell -EncodedCommandto survive spaces in profile paths. Combined with the inner PowerShellInvoke-WebRequestpost (#2100), every hook spawned two PowerShell processes (~280–410ms startup each, measured) → ~650ms+ per hook, fired up to 6× per turn. Codex 0.140 renders that as lingeringRunning <event> hookrows.A prior RC worked around this by deleting
SessionStart/UserPromptSubmit/Stop, which loses lifecycle status fidelity. This PR keeps all six events and makes them fast instead.Fix
Codex (executes hooks as
cmd.exe /C <command>):.cmdpath for cmd-safe profiles → Codex runs it directly with zero shell startup. Spaced/metachar paths still fall back to the encoded PowerShell launcher (preserves [Bug]: Codex hooks fail on Windows when user path contains spaces #6078 robustness).curl.exe(Windows 10 1803+), posting the same form fields as the POSIX hook and reading the raw payload from stdin via--data-urlencode payload@-so UTF-8 (e.g. CJK) survives without code-page translation.Claude (executes hooks through Git Bash):
curl.exetoo → 2 PowerShell startups → 1.Validation
Against the real Codex 0.140 binary (interactive TUI via node-pty +
codex exec):state: "installed"(all 6 events present and trust hashes match) in a dev build off this branch.cmd.exeand asserts UTF-8 (CJK) + a worktreeId with spaces and&survive.65 passed | 3 skipped; typecheck + lint clean.Notes
🤖 Generated with Claude Code