Add opt-in overhead timing to code-mode responses (#46288)

## Why

Code-mode responses show host duration without exposing time spent outside the host, including app-server waiting.

## What changed

- Add `features.code_mode.experimental_show_cell_overhead`, disabled by default, to show handler duration, host duration, and their difference in `exec` and `wait` response headers.
- Reuse the completed handler measurement from tool-call logging, excluding dispatch waiting, and capture it even when logging is disabled.
- Preserve the existing timing format when the option is disabled or host timing is unavailable, and preserve boolean feature toggles when merging nested code-mode configuration.

## Testing

Add coverage for timing headers, zero and missing host measurements, negative rounding differences, content preservation, and configuration merging. Extend app-server tests across gRPC and stdio to verify timing includes post-host elicitation waiting, and add a response snapshot for successful execution and a failed wait.

GitOrigin-RevId: 929b84784d9c6077cf2b5927a90bd2d5f3870078
This commit is contained in:
cassirer-openai
2026-09-17 19:34:45 +00:00
committed by copyberry
parent 0a5b999169
commit 0fd1cd8d99
19 changed files with 619 additions and 116 deletions
+8
View File
@@ -18,6 +18,10 @@ pub trait ToolOutput: Send {
fn success_for_logging(&self) -> bool;
/// Finalizes output using the same completed handler duration reported in tool-call logs.
/// Called before recording model-visible history; implementations must not measure time here.
fn set_handler_duration_ms(&mut self, _handler_duration_ms: u64) {}
/// Whether this output contains external context that should disable memory generation when
/// `memories.disable_on_external_context` is enabled.
fn contains_external_context(&self) -> bool {
@@ -75,6 +79,10 @@ where
(**self).success_for_logging()
}
fn set_handler_duration_ms(&mut self, handler_duration_ms: u64) {
(**self).set_handler_duration_ms(handler_duration_ms);
}
fn contains_external_context(&self) -> bool {
(**self).contains_external_context()
}