Attribute approval waits to tool critical-path timing (#57207)

## Why

Automatic reviews and user prompts previously invalidated critical-path captures even when their owning tool invocation was known.

## What changed

Record automatic review time as `auto_review` and waits for approvals, permission requests, and user input as `user_wait` when `CriticalPathTiming` is enabled. Bind timing to the owning invocation before asynchronous work begins, and use the triggering tool's identity for network approvals. Continue invalidating captures when a wait cannot be attributed.

## Testing

Add coverage for cancellation, reused call IDs, network ownership, and disabled capture. Update the automatic review integration test to verify attributed review duration.

GitOrigin-RevId: 0a1f5feebd0c4f5ed67dc058e832ec5f8818db02
This commit is contained in:
taohong-oai
2026-10-26 19:28:51 +00:00
committed by copyberry
parent e1c87d1c2d
commit 7c997fe2de
6 changed files with 359 additions and 66 deletions
+4
View File
@@ -752,6 +752,7 @@ impl Session {
ExecApprovalKind::Command,
ctx.review_context.model_context(),
ctx.call_id.clone(),
Some(&ctx.call_id),
/*approval_id*/ None,
Some(environment_id.clone()),
command.clone(),
@@ -782,6 +783,7 @@ impl Session {
ExecApprovalKind::WriteStdin,
ctx.review_context.model_context(),
id.clone(),
Some(&ctx.call_id),
Some(approval_id.clone()),
Some(environment_id.clone()),
vec![
@@ -852,6 +854,7 @@ impl Session {
environment_id,
command,
cwd,
trigger,
..
} => {
self.request_command_approval(
@@ -859,6 +862,7 @@ impl Session {
ExecApprovalKind::Command,
ctx.review_context.model_context(),
ctx.call_id.clone(),
trigger.as_ref().map(|trigger| trigger.call_id.as_str()),
/*approval_id*/ None,
Some(environment_id.clone()),
command.clone(),