mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Cancel Guardian reviews with their tool calls (#40021)
## What changed Propagate tool cancellation tokens into Guardian approval reviews so interrupting a tool also aborts its pending review. Apply the same cancellation behavior to server-initiated MCP approval elicitation. ## Testing Add integration coverage for cancellation from direct tool calls, code-mode turns, background code-mode cells, and MCP elicitation. GitOrigin-RevId: cbee4b422bbcbf6984e415ef6409cee705beebdc
This commit is contained in:
1 parent
677cfee000
commit
6143217c67
22 files changed
+500
-22
No files matched your search
@@ -5,6 +5,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use crate::apply_patch;
|
||||
use crate::apply_patch::convert_apply_patch_to_protocol;
|
||||
@@ -370,6 +371,7 @@ impl ApplyPatchHandler {
|
||||
session,
|
||||
turn,
|
||||
step_context,
|
||||
cancellation_token,
|
||||
tracker,
|
||||
call_id,
|
||||
tool_name,
|
||||
@@ -419,6 +421,7 @@ impl ApplyPatchHandler {
|
||||
let tool_ctx = ToolCtx {
|
||||
session,
|
||||
step_context: Arc::clone(&step_context),
|
||||
cancellation_token,
|
||||
call_id,
|
||||
tool_name,
|
||||
};
|
||||
@@ -509,6 +512,7 @@ pub(crate) async fn intercept_apply_patch(
|
||||
turn_environment: TurnEnvironment,
|
||||
session: Arc<Session>,
|
||||
step_context: Arc<StepContext>,
|
||||
cancellation_token: CancellationToken,
|
||||
tracker: Option<&SharedTurnDiffTracker>,
|
||||
call_id: &str,
|
||||
tool_name: &str,
|
||||
@@ -529,6 +533,7 @@ pub(crate) async fn intercept_apply_patch(
|
||||
let tool_ctx = ToolCtx {
|
||||
session,
|
||||
step_context,
|
||||
cancellation_token,
|
||||
call_id: call_id.to_string(),
|
||||
tool_name: ToolName::plain(tool_name),
|
||||
};
|
||||
|
||||
@@ -173,6 +173,7 @@ impl McpHandler {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
step_context,
|
||||
cancellation_token,
|
||||
call_id,
|
||||
tool_name,
|
||||
payload,
|
||||
@@ -193,6 +194,7 @@ impl McpHandler {
|
||||
let result = handle_mcp_tool_call(
|
||||
Arc::clone(&session),
|
||||
&step_context,
|
||||
&cancellation_token,
|
||||
call_id.clone(),
|
||||
&self.tool_info,
|
||||
self.hook_tool_name(),
|
||||
|
||||
@@ -112,6 +112,7 @@ impl ExecCommandHandler {
|
||||
session,
|
||||
turn,
|
||||
step_context,
|
||||
cancellation_token,
|
||||
tracker,
|
||||
call_id,
|
||||
payload,
|
||||
@@ -128,8 +129,12 @@ impl ExecCommandHandler {
|
||||
};
|
||||
|
||||
let manager: &UnifiedExecProcessManager = &session.services.unified_exec_manager;
|
||||
let context =
|
||||
UnifiedExecContext::new(session.clone(), step_context.clone(), call_id.clone());
|
||||
let context = UnifiedExecContext::new(
|
||||
session.clone(),
|
||||
step_context.clone(),
|
||||
cancellation_token,
|
||||
call_id.clone(),
|
||||
);
|
||||
let environment_args: ExecCommandEnvironmentArgs = parse_arguments(&arguments)?;
|
||||
let Some(turn_environment) = resolve_tool_environment(
|
||||
&step_context.environments,
|
||||
@@ -318,6 +323,7 @@ impl ExecCommandHandler {
|
||||
turn_environment.clone(),
|
||||
context.session.clone(),
|
||||
Arc::clone(&context.step_context),
|
||||
context.cancellation_token.clone(),
|
||||
Some(&tracker),
|
||||
&context.call_id,
|
||||
"exec_command",
|
||||
|
||||
Reference in new issue
Block a user