Preserve delivered messages through post-tool hook failures (#47039)

## Why

Guardian can lose a confirmed User Messaging message from its parent context when a `PostToolUse` hook blocks the result or is cancelled. The message has already been sent and remains relevant to interpreting the user's authorization.

## What changed

Capture confirmed message text after input-rewriting hooks in shared per-call state before awaiting post-tool processing. Attach that evidence to the response metadata even when dispatch returns a blocked or aborted result, while keeping post-tool hooks cancellable. Calls cancelled before delivery confirmation contribute no message evidence.

## Testing

Extend Guardian subagent authorization coverage to verify retained messages after post-tool hook blocking and cancellation, and their absence when cancellation precedes delivery confirmation.

GitOrigin-RevId: 9abb7959980eada20d0fb5c0b3a4a8669e4cd0a3
This commit is contained in:
felixxia-oai
2026-09-21 14:14:21 +00:00
committed by copyberry
parent 87bc50f9d4
commit 3483294596
10 changed files with 198 additions and 86 deletions
+1
View File
@@ -402,6 +402,7 @@ fn submit_nested_tool(
runtime_tool_call_id,
},
cancellation_token,
Arc::default(),
);
Ok(async move { Ok(result.await?.code_mode_result()) })
}