mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Capture direct-tool critical paths behind a feature flag (#57201)
## What changed Add the default-disabled `critical_path_timing` feature to capture dependency paths for root-agent turns. Connect direct tool dispatch, execution-lock handoffs, and completed tool batches to turn timing so overlapping work shares its common history without double counting. Omit captures for unsupported dependencies, including CodeMode, agent communication, approval review, and user waits. Settle aborted tasks before freezing timing, invalidate captures on forced teardown, and apply runtime feature changes only to future turns. ## Testing Add coverage for serial and overlapping tool dispatch, execution-lock dependency handoffs, cancellation, unsupported paths, frozen timing after completion, and configuration refresh boundaries. GitOrigin-RevId: 71458b654b1c4a05799886928b449c948ea33109
This commit is contained in:
@@ -96,6 +96,38 @@ pub fn mcp_attribution_snapshot(
|
||||
.mcp_attribution_snapshot()
|
||||
}
|
||||
|
||||
/// Retains the active turn's timing after completion without exporting telemetry.
|
||||
/// Returns `None` when there is no running task. The observer reports exclusive
|
||||
/// durations for the caller's interval in inference, automatic review, local
|
||||
/// tools, overhead, and unknown order.
|
||||
pub async fn observe_turn_timing(
|
||||
thread: &crate::CodexThread,
|
||||
) -> Option<
|
||||
impl Fn(std::time::Instant, std::time::Instant) -> Option<[std::time::Duration; 5]> + use<>,
|
||||
> {
|
||||
let active = thread.session.active_turn.lock().await;
|
||||
let timing = Arc::clone(
|
||||
&active
|
||||
.as_ref()?
|
||||
.task
|
||||
.as_ref()?
|
||||
.turn_context
|
||||
.turn_timing_state,
|
||||
);
|
||||
Some(move |start, end| {
|
||||
timing.snapshot_path(end).map(|path| {
|
||||
let totals = path.durations(start, end);
|
||||
[
|
||||
totals.inference,
|
||||
totals.auto_review,
|
||||
totals.tools,
|
||||
totals.overhead,
|
||||
totals.unknown,
|
||||
]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Test-only provider that supplies no user instructions.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EmptyUserInstructionsProvider;
|
||||
|
||||
Reference in New Issue
Block a user