Correlate code mode tool analytics with model responses (#36729)

## What changed

- Emit dynamic tool-call analytics for code mode `exec` and `wait` calls, including duration and terminal status.
- Associate code-mode cells and their nested tool calls with the originating and subsequent model response IDs.
- Buffer correlated tool events until the next response is known, while flushing pending events when turns, threads, or the analytics queue close.

## Testing

- Add reducer coverage for correlating `exec`, `wait`, and nested tool events across turns.
- Add an app-server test that verifies production analytics include the cell and response IDs for a code-mode `exec` call.

GitOrigin-RevId: 8b34ab59c1ad68ebbd57f9c8a05f19ab04df48a4
This commit is contained in:
jif authored and copyberry committed 2026-08-03 10:19:04 +00:00
1 parent dae2122214
commit 155f1ca9e5
13 files changed
+797 -35

No files matched your search

+11 -1
View File
@@ -141,6 +141,9 @@ impl AnalyticsEventsQueue {
let input = match input {
AnalyticsEventsQueueMessage::Fact(input) => *input,
AnalyticsEventsQueueMessage::Flush(done_tx) => {
let mut events = Vec::new();
reducer.flush(&mut events);
send_track_events(&auth_manager, &destination, events).await;
let _ = done_tx.send(());
continue;
}
@@ -288,6 +291,12 @@ impl AnalyticsEventsClient {
));
}
pub fn track_code_mode_tool_call(&self, input: crate::facts::CodeModeToolCallFact) {
self.record_fact(AnalyticsFact::Custom(
CustomAnalyticsFact::CodeModeToolCall(input),
));
}
pub fn track_guardian_review(
&self,
tracking: &GuardianReviewTrackContext,
@@ -607,7 +616,8 @@ impl AnalyticsEventsClient {
pub fn track_notification(&self, notification: &ServerNotification) {
if !matches!(
notification,
ServerNotification::TurnStarted(_)
ServerNotification::ThreadClosed(_)
| ServerNotification::TurnStarted(_)
| ServerNotification::TurnCompleted(_)
| ServerNotification::TurnDiffUpdated(_)
| ServerNotification::ItemStarted(_)