From d70a0bc76729689f863a5a0a95183058f476e42e Mon Sep 17 00:00:00 2001 From: Abhinav Vedmala Date: Fri, 22 May 2026 09:34:30 -0700 Subject: [PATCH] Explain hook opt outs --- codex-rs/core/src/tools/code_mode/wait_handler.rs | 6 ++++++ .../core/src/tools/handlers/unified_exec/write_stdin.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/codex-rs/core/src/tools/code_mode/wait_handler.rs b/codex-rs/core/src/tools/code_mode/wait_handler.rs index 1630249716..d0c0453df6 100644 --- a/codex-rs/core/src/tools/code_mode/wait_handler.rs +++ b/codex-rs/core/src/tools/code_mode/wait_handler.rs @@ -115,6 +115,10 @@ impl ToolExecutor for CodeModeWaitHandler { impl CoreToolRuntime for CodeModeWaitHandler { fn pre_tool_use_payload(&self, _invocation: &ToolInvocation) -> Option { + // Code-mode `wait` is runtime control for an existing code cell, not a + // standalone user action. Tool calls made from code mode still flow + // through normal dispatch, but hooks should not block or rewrite the + // wait loop itself. None } @@ -123,6 +127,8 @@ impl CoreToolRuntime for CodeModeWaitHandler { _invocation: &ToolInvocation, _result: &dyn ToolOutput, ) -> Option { + // The wait result feeds code-mode control flow, so do not let + // PostToolUse replace it with model-facing hook feedback. None } } diff --git a/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs b/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs index 0491ace02d..a639ea0065 100644 --- a/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs +++ b/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs @@ -103,6 +103,9 @@ impl CoreToolRuntime for WriteStdinHandler { } fn pre_tool_use_payload(&self, _invocation: &ToolInvocation) -> Option { + // `write_stdin` is transport for an existing exec session. Empty writes + // are background polls, and non-empty writes continue a command that + // already ran PreToolUse as Bash, so do not emit a second pre hook here. None } @@ -111,6 +114,8 @@ impl CoreToolRuntime for WriteStdinHandler { invocation: &ToolInvocation, result: &dyn crate::tools::context::ToolOutput, ) -> Option { + // A `write_stdin` poll can observe final completion for the original + // `exec_command`; emit that command's matching Bash PostToolUse. post_unified_exec_tool_use_payload(invocation, result) } }