Skip to content

fix(hooks): send Codex a decision it enforces, not Cursor's - #246

Merged
blitzcrieg1 merged 2 commits into
masterfrom
fix/codex-hook-decision
Oct 13, 2026
Merged

blitzcrieg1 merged 2 commits into
masterfrom
fix/codex-hook-decision

Conversation

@blitzcrieg1

Copy link
Copy Markdown
Owner

What was wrong

The 0.9.0 fix that gave each agent its own hook decision format missed Codex. codex is not in _CLAUDE_PROTOCOL, so _decision_output fell through to Cursor's {"permission": "deny"} with exit code 0.

Codex parses hook output with serde deny_unknown_fields (codex-rs/hooks/src/schema.rs). Output it cannot parse is marked Failed and the tool runs (events/pre_tool_use.rs, the looks_like_json branch). So every DLP and tool-policy block on Codex failed open, while the trail recorded the call as outcome: denied.

Found while building an agent coverage matrix. No test covered Codex's deny output.

The fix

_codex_decision_output in hooks/ingest.py, following Codex's parser at openai/codex 806d2d1 (2026-10-08):

Decision PreToolUse PermissionRequest
deny hookSpecificOutput.permissionDecision: "deny", plus a reason that is never empty (Codex rejects an empty one) decision.behavior: "deny", plus message
ask sent as deny (Codex parses ask and rejects it) sent as deny
allow {} (Codex rejects allow without updatedInput) behavior: "allow"

Every other agent's format is unchanged.

Tests

  • 11 new tests validate each Codex decision against the two output schemas Codex publishes, copied unchanged into tests/fixtures/codex_hooks/ (Apache-2.0, source commit recorded in the README there). They also apply the rejections the schemas can't express.
  • All 11 fail on the old code and pass with the fix.
  • One end-to-end test runs a policy block through hook_main with Codex's Bash input.
  • README collected count bumped to 1650.
  • Ruff is clean, agentmetry benchmark shows 0 missed and 0 false positives, and the fingerprint is still 15846a0915769d4a. No frozen file is touched.

Not verified

  • No live Codex run. Codex was not run. The fix is checked against its parser source and schemas.
  • README pass line is stale. It still says "1631 passed and 8 skipped". It needs this PR's Python 3.12 CI figures.
  • Existing Codex trails may hold denied events for calls that ran. The CHANGELOG entry says so.

Worth a 0.9.5 release once merged.

🤖 Generated with Claude Code

blitzcrieg1 and others added 2 commits October 12, 2026 23:24
The 0.9.0 fix that gave each agent its own decision format missed Codex.
It kept receiving Cursor's {"permission": "deny"}. Codex parses hook
output with serde deny_unknown_fields, so it rejected that as invalid,
marked the hook run failed, and ran the tool. The hook had already
written the call to the trail as outcome: denied. Every DLP and
tool-policy block on Codex failed open, and the record said it worked.

Codex now gets its own schema. Three more of its rejections, each also
a silent allow, are handled: a deny always carries a non-empty reason,
an ask is sent as deny (parsed, not supported), and an allow is {}
rather than an allow without updatedInput.

The tests validate every Codex decision against the output schemas
Codex publishes (openai/codex 806d2d1, Apache-2.0, copied into
tests/fixtures/codex_hooks/), because a shape check is what certified
the wrong format last time. All 11 new tests fail on the old code.
Checked against Codex's parser source; Codex itself was not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
1642 passed and 8 skipped (1650 collected), coverage 82%, from the
orchestrator (ubuntu-latest) job on f6fef75.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blitzcrieg1
blitzcrieg1 merged commit 5abe21f into master Oct 13, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 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.

1 participant