You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hooks: PostToolUse is missing for tools that complete via exec session / polling path #16246
Codex emits PreToolUse for shell tools started via exec_command, but in some cases it never emits the matching PostToolUse.
This appears to happen specifically when the command does not complete on the initial exec_command call and instead completes later through the long-running session / polling path.
Expected behavior
Every tool call that emits PreToolUse should emit exactly one matching PostToolUse when the tool finishes, regardless of whether it:
completes immediately on the initial tool call, or
completes later through the session continuation / polling flow
Actual behavior
PostToolUse is emitted for commands that complete immediately, but is missing for commands that:
start via exec_command
return a running session
later complete through the session / polling path
Evidence
In one reproduced case, a single turn produced:
7PreToolUse
2PostToolUse
The transcript for that same turn showed that the missing tool calls did in fact complete successfully later, including exit codes and output, but no PostToolUse event was emitted for them.
The missing cases were long-running shell commands that first returned a session and later completed through polling. The two cases that did get PostToolUse were commands that completed directly on the initial exec_command path.
Impact
Consumers that rely on hooks to model tool lifecycle get incomplete traces:
tools appear to start but never finish
duration and status are missing
downstream systems cannot reliably pair pre/post tool events
Root-cause hypothesis
The hook integration appears to emit PostToolUse only for the immediate completion path, but not for tool completion that happens later through the exec session continuation / polling path.
Suggested fix
Emit PostToolUse when the tool actually completes, regardless of whether completion happens:
during the initial exec_command, or
during later session polling / continuation
The emitted event should use the original tool call ID so consumers can pair it with the earlier PreToolUse.
Indexed this hook ticket in the umbrella tracker: #21753
Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.
Activity
JaysonGeng commentedon Mar 31, 2026
I put together a fix on my fork.
Commit:
5dc02dbBranch:
fix/post-tool-use-on-exec-session-completionFork compare: JaysonGeng/codex@main...fix/post-tool-use-on-exec-session-completion
Upstream compare: https://github.com/openai/codex/compare/main...JaysonGeng:codex:fix/post-tool-use-on-exec-session-completion?expand=1
What changed:
PostToolUsePayloadis now computed before handler output is type-erased, sounified_execcan attach completion metadata fromExecCommandToolOutput.exec_commandsessions preserve the original tool call ID and rawcmd, and reuse them whenwrite_stdinreports completion.write_stdincompletion payload and a hooks integration regression forexec_command -> write_stdin -> completion.Validation:
cargo check -p codex-core --tests./target/debug/deps/codex_core-db6849df46c54ae2 tools::handlers::unified_exec::tests::write_stdin_post_tool_use_payload_uses_original_exec_call_id_and_command_on_completion --exact./target/debug/deps/all-677a7268d57df65b suite::hooks::post_tool_use_exit_two_replaces_one_shot_exec_command_output_with_feedback --exact./target/debug/deps/all-677a7268d57df65b suite::hooks::post_tool_use_fires_when_exec_session_completes_via_write_stdin --exactjust fmtjust fix -p codex-coregit diff --checkjust argument-comment-lintcould not run locally becausebazelis not installed in this environment.I know
docs/contributing.mdsays external contributions are by invitation only, so I’m posting the compare links here instead of opening a PR.hooks: emit Bash PostToolUse when exec_command completes via write_st…
hooks: emit Bash PostToolUse when exec_command completes via write_st…
hooks: emit Bash PostToolUse when exec_command completes via write_st…
oxysoft commentedon May 8, 2026
Indexed this hook ticket in the umbrella tracker: #21753
Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.
ci(dist): drop dead fsqlite git-dep Windows long-path workaround; doc…
hooks: emit Bash PostToolUse when exec_command completes via write_st…