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

+3 -8
View File
@@ -793,7 +793,7 @@ pub(crate) fn spawn_approval_request_review(
context: impl Into<GuardianReviewContext>,
review_id: String,
request: GuardianApprovalRequest,
retry_reason: Option<String>,
reasons: ApprovalRequestReasons,
options: GuardianReviewOptions,
) -> oneshot::Receiver<ReviewDecision> {
let context = context.into();
@@ -802,13 +802,8 @@ pub(crate) fn spawn_approval_request_review(
let spawn_result = std::thread::Builder::new()
.name("codex-approval-review".to_string())
.spawn(move || {
let decision = runtime.block_on(review_approval_request_with_cancel(
&session,
context,
review_id,
request,
retry_reason,
options,
let decision = runtime.block_on(run_guardian_review(
session, context, review_id, request, reasons, options,
));
let _ = tx.send(decision);
});