Skip to content

fix: trust Codex session hooks on Windows - #1244

Merged
mnajafian-nv merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1000-codex-windows-hook-trust
Oct 7, 2026
Merged

mnajafian-nv merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1000-codex-windows-hook-trust

Conversation

@willkill07

@willkill07 willkill07 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Overview

Fix Codex hook trust for managed Windows runs. Relay currently creates session hook trust entries with a Unix source path, while Codex 0.160.1 discovers those hooks under C:\<session-flags>\config.toml. The unmatched trust entries allow collaboration to execute without emitting the hooks needed for sub-agent and tool scopes.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Use the platform-specific synthetic session-flags path when constructing exact hook trust keys.
  • Add regression coverage for Windows and Unix discovery paths, including TOML backslash escaping and trust entries for session, tool, and sub-agent lifecycle hooks.
  • Update the existing discovery-identity test to accept the native platform path.

Validation:

  • Focused Codex hook-trust tests: 2 passed.
  • just test-rust: all 5,757 tests passed on macOS.
  • An isolated Codex 0.160.1 mock-provider probe completed SpawnAgent, Wait, and CloseAgent with zero hooks when trust keys did not match. Matching keys emitted sub-agent start/stop and pre/post hooks for all three collaboration operations.
  • Staged pre-commit checks passed, including formatting, Clippy, workspace checks, documentation links, and dependency audits.
  • Native Windows ATOF validation remains outstanding, including child model-call parentage and balanced scope closure.

No public API or breaking changes.

Where should the reviewer start?

Start with session_hook_state_override_for_platform in crates/cli/src/agents/codex/launch.rs, then codex_session_hook_trust_uses_platform_discovery_paths in crates/cli/tests/coverage/agents/launcher_tests.rs.

Codex's synthetic source path is defined in Codex 0.160.1 hook discovery.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes
    • Codex session hooks now correctly recognize trusted hook settings on Windows and other platforms by checking the appropriate configuration location. This fixes cases where trusted hooks might not be recognized on Windows and keeps trust handling consistent across platforms and hook events.

@willkill07
willkill07 requested a review from a team as a code owner October 7, 2026 13:35
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: d3a17db3-8971-4360-a6dc-5bab561465e7
📥 Commits

Reviewing files that changed from the base of the PR and between 3488069 and 7ad8b3b.

📒 Files selected for processing (2)
  • crates/cli/src/agents/codex/launch.rs
  • crates/cli/tests/coverage/agents/launcher_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Prepare
🧰 Additional context used
📓 Path-based instructions (1)
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/agents/launcher_tests.rs
🔇 Additional comments (2)
crates/cli/src/agents/codex/launch.rs (1)

154-154: LGTM!

Also applies to: 163-167, 194-194

crates/cli/tests/coverage/agents/launcher_tests.rs (1)

729-729: LGTM!

Also applies to: 734-739, 758-795


Walkthrough

The Codex session-hook override now selects a session-flags configuration path for Windows or non-Windows platforms. Tests check trusted-hook entries for both paths.

Changes

Codex hook paths

Layer / File(s) Summary
Select and verify platform-specific paths
crates/cli/src/agents/codex/launch.rs, crates/cli/tests/coverage/agents/launcher_tests.rs
A platform-aware helper selects the session-flags path used in trusted-hook state keys. Tests verify enabled entries with SHA-256 hashes for five hook events on both platform modes. The Windows test also checks that the non-Windows path is absent.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: DO NOT MERGE

Merge Risk: ⚪ Minimal · up to 7ad8b

Windows trust entries now use Codex’s Windows-specific synthetic path while Unix entries retain their existing path. The reviewed change presents no concrete new user-facing risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title follows Conventional Commits format with the allowed lowercase type fix, uses an imperative summary, stays under 72 characters, and has no trailing period.
Description check ✅ Passed The description includes all required template sections, completed contribution checks, implementation details, reviewer guidance, related issue information, and validation results. It clearly disclos…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the DO NOT MERGE PR should not be merged; see PR for details label Oct 7, 2026
@willkill07 willkill07 self-assigned this Oct 7, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 7, 2026
@willkill07 willkill07 removed the DO NOT MERGE PR should not be merged; see PR for details label Oct 7, 2026

@mnajafian-nv mnajafian-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mnajafian-nv
mnajafian-nv merged commit 4aa3f80 into NVIDIA:release/0.10 Oct 7, 2026
46 checks passed
willkill07 added a commit that referenced this pull request Oct 7, 2026
#### Overview

Fix Windows Codex hooks failing to execute, which leaves sub-agent and
collaboration tool scopes missing from ATOF traces. Codex runs hooks
through its session shell, which defaults to PowerShell on Windows;
Relay currently generates cmd.exe syntax.

- [x] I confirm this contribution is my own work, or I have the right to
submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does
not duplicate existing work.

#### Details

- Generate Windows Codex hook commands as encoded PowerShell scripts
with literal argument quoting, including ASCII and smart apostrophes.
- Stop on invocation errors so a missing Relay executable fails instead
of reporting success.
- Preserve the Relay exit code through both PowerShell layers, including
code 2 used for hook denials.
- Exercise argument paths with spaces, Unicode, apostrophes and shell
characters, stdin forwarding, stdout/stderr, native exit codes and a
missing executable in PowerShell 5 and 7.
- Run PowerShell 7 regressions only when installed, and decode
PowerShell literals correctly in test assertions.
- Keep other agents' command rendering unchanged. No public API or
breaking changes.

Validation:

- `just test-rust` and `uv run pre-commit run` passed on this branch.
- Native Windows regressions passed on `x1carbon` in PowerShell 5 and 7
using cross-compiled Rust binaries and the repository's native hook
fixture.
- Real Codex 0.160.1 runs against a deterministic localhost Responses
provider spawned one and three sub-agents. ATOF contained all expected
sub-agent and collaboration tool scopes, child model calls had correct
parentage, and every scope closed.
- Windows end-to-end validation used PR #1256's inspected head plus the
original Codex hook fix. Follow-up review fixes were validated with
native Windows execution tests in PowerShell 5 and 7, including a run
with PowerShell 7 absent from PATH. The worker fix's release backport is
tracked separately in #1257 and is excluded from this PR.
- Python and Node binding suites were not run because their contracts
are unchanged.

#### Where should the reviewer start?

Start with `render_hook_command` in `crates/cli/src/hooks/encoding.rs`,
particularly literal PowerShell argument encoding and exit-code
propagation. Then review the Windows execution regressions in
`crates/cli/tests/coverage/agents/plugin_host_tests.rs`.

#### Related Issues: (use one of the action keywords Closes / Fixes /
Resolves / Relates to)

- Fixes
[RELAY-1000](https://linear.app/nvidia/issue/RELAY-1000/nemo-relay0100-rc3windowscodex-sub-agent-and-collaboration-tool-scopes).
- Relates to #1244, which addressed Windows hook trust; this fixes the
remaining hook command execution failure.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved Windows hook execution for Codex in PowerShell and PowerShell
7. Hook commands now handle paths containing spaces, special characters,
apostrophes, smart quotes, and Unicode while preserving input, output,
and exit codes.
  * Missing hook relays now report an error and return a failure code.
* Claude Code and pi continue using their existing hook command
behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>
@willkill07
willkill07 deleted the fix/relay-1000-codex-windows-hook-trust branch October 30, 2026 14:47

This branch was previously deployed

1 inactive deployment
fern — 7ad8b3b1 Deployed Oct 7, 2026 by mnajafian-nv via Clean up docs preview #5476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants