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:
Won Park authored and copyberry committed 2026-08-21 21:51:12 +00:00
1 parent 677cfee000
commit 6143217c67
22 files changed
+500 -22

No files matched your search

+1 -1
View File
@@ -2575,6 +2575,7 @@ impl Session {
};
let approval_context = ApprovalContext {
review_context: review_context.clone(),
cancellation_token: Some(cancellation_token.clone()),
call_id,
tool_name: ToolName::plain("request_permissions"),
strict_auto_review: false,
@@ -2588,7 +2589,6 @@ impl Session {
decision = self.request_guardian_approval(
action,
&approval_context,
Some(cancellation_token.clone()),
) => decision,
};
let response = match decision {