mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Let required hooks block continuation on failure (#62831)
## Why A required hook check can fail to run or return a usable result. Continuing after that failure can let an action proceed without a completed check. ## What changed Add per-handler `onFailure` for command and MCP tool hooks. The default `continue` preserves existing behavior. On supported synchronous hooks, `block` applies the event's blocking behavior and reports the reason while preserving failure diagnostics. For example, a failed `PreToolUse` check prevents the tool from running, while a failed `PostToolUse` check withholds the result of a tool that already ran. Expose the policy in the app-server's `configRequirements/read` response. ## Testing Add tests for command and MCP failures under both policies, and scenario coverage for blocked tool execution, withheld results, and completion after a `Stop` hook recovers. GitOrigin-RevId: 20d6ebda0094382fe052bbf34338edb994cc7bd3
This commit is contained in:
@@ -247,6 +247,8 @@ pub(crate) async fn run_pre_tool_use_hooks(
|
||||
};
|
||||
};
|
||||
|
||||
let reason = reason.trim_end_matches('.');
|
||||
|
||||
if (tool_name.name() == "Bash" || tool_name.name() == "apply_patch")
|
||||
&& let Some(command) = tool_input.get("command").and_then(Value::as_str)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user