openai / openai/codex

PreToolUse hook rejects valid command rewrite unless `permissionDecision: "allow"` is also returned

Open
#46,664 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI hooks
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What issue are you seeing?

PreToolUse hook rejects valid command rewrite unless permissionDecision: "allow" is also returned

Environment
  • OS: Windows 11 Pro
  • Codex CLI: 0.155.1
  • Codex executable:
    C:\Users\getra\AppData\Local\Programs\OpenAI\Codex\bin\codex.exe
  • sctx: 0.10.0
  • sctx executable:
    C:\Users\getra\.local\bin\sctx.exe
  • Codex home:
    C:\Users\getra\.codex
What steps can reproduce the bug?
Problem

The official sctx Codex PreToolUse integration attempts to rewrite shell commands through sctx.

For example:

git status

should be rewritten to:

sctx git status

sctx returns an updatedInput value containing the rewritten command.

However, Codex rejects the hook response because it does not also contain:

"permissionDecision": "allow"

Codex reports:

PreToolUse Failed

and then executes the original command without the sctx wrapper.

What is the expected behavior?
Expected behavior

A PreToolUse hook that only wants to rewrite the tool input should either:

  1. be allowed to return updatedInput without an explicit permission decision, or
  2. the hook contract/documentation/schema should clearly require permissionDecision: "allow" when updatedInput is returned.

The rewritten command should then be executed.

Additional information
Actual behavior

The hook rewrite fails validation.

Codex then runs the original command instead:

git status

rather than:

sctx git status
Verification

Direct sctx usage works correctly.

Tests performed successfully:

  • sctx doctor
  • direct Git command through sctx
  • direct ripgrep command through sctx
  • non-zero exit code preservation
  • raw-output recovery

The failure occurs specifically at the Codex PreToolUse integration boundary.

A fresh Codex session was used to rule out stale configuration.

Additional context

The same sctx installation successfully integrates with Claude Code.

This appears to be either:

  • a Codex hook schema/validation compatibility issue, or
  • a requirement that third-party hook authors must always return permissionDecision: "allow" together with updatedInput.

It would be helpful to clarify the intended PreToolUse contract.

Potentially related:

  • #25555 — Hook output schemas allow values later rejected by parser
  • #32544 — PreToolUse updatedInput rewrite behavior
  • #18491 — PreToolUse / updatedInput rewrite support
Reproduction outline
  1. Install Codex CLI 0.155.1.
  2. Configure a trusted PreToolUse hook.
  3. Have the hook return a valid updatedInput command rewrite but no explicit permissionDecision.
  4. Start a fresh Codex session.
  5. Run a harmless shell command such as git status.
  6. Observe PreToolUse Failed.
  7. Observe that Codex executes the original command instead of the rewritten command.
Desired outcome

Either:

  • permit updatedInput-only rewrites, or
  • document/enforce a clear schema requiring something equivalent to:
{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "updatedInput": {
      "command": "sctx git status"
    }
  }
}

so integrations such as sctx can implement the Codex hook contract reliably.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the PreToolUse hook validation and parsing entry points, focusing on the interaction between updatedInput and permissionDecision. Compare the behavior with related issues #25555, #32544, and #18491. Done means rewrite-only responses are accepted or the required response shape is clearly enforced and documented, with coverage for a git status-style rewrite.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.