openai / openai/codex

exec_command reports running before command dispatch while awaiting hook approval

Open
#45,469 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI hooks sandbox tool-calls
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What issue are you seeing?

When an exec_command tool call is held by a blocking PermissionRequest approval hook, Codex returns this model-visible tool state:

Script running with cell ID 45

The hook command is running, the requested shell command has not started.

That state is indistinguishable from a command that was dispatched and is now hung or legitimately long-running. The agent therefore diagnoses the wrong layer: it polls the cell, searches the process table, terminates the cell, or retries the command. A retry can create another long running hook.

What steps can reproduce the bug?
  1. Use Codex with a hook that runs for longer time durations.
  2. Run an exec_command that is expected to finish quickly.
  3. The LLM thinks the shell command / tool call itself hung and may attempt to debug it although it didn't even run.

Environment:

  • Codex CLI 0.154.0, confirmed current by codex doctor
  • Model: gpt-5.6-sol
  • Platform: Darwin 25.5.0 arm64 arm
  • Terminal: VS Code 1.137.0
  • unified_exec and hooks enabled
What is the expected behavior?

The tool protocol should expose the pre-dispatch phase explicitly, for example:

{
  "status": "waiting_for_hook",
  "hook_command": "...",
  "command_started": false,
  "cell_id": "45"
}

Only report running after the requested command has actually been dispatched.

At minimum, the model-visible text should say that execution is waiting for hooks to complete and that the shell command has not started.

Additional information

Impact:

  • Agents falsely diagnose healthy shell commands or repository hooks as hung.
  • Agents terminate cells that haven't really executed.
  • Agents retry and can create duplicate long running hooks.
  • Users receive incorrect explanations about what is blocking execution.

Related but not duplicate: #39835 requests racing a PermissionRequest hook with the terminal approval prompt. This report concerns the exec_command lifecycle state exposed to the model while a hook command is pending.

The repository was searched across open and closed issues for hook waiting, command running, hanging command, and pre-dispatch lifecycle reports. No issue describing this protocol-state ambiguity was found.

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 exec_command lifecycle and the PermissionRequest approval hook, focusing on how the model-visible running state is emitted before dispatch. Trace the state transition from hook approval through command start. Done means hook-blocked calls clearly report that the shell command has not started, while running is reported only after dispatch.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.