Include item start times in completion events (#35363)

## What changed

- Add an optional `started_at_ms` field to `ItemCompletedEvent`, retaining
  compatibility with older persisted events that lack it.
- Track the first start timestamp for each in-flight item and attach it when
  emitting and persisting the completion event. If no start was recorded, use
  the completion timestamp as a fallback.
- Emit a complete start/completion lifecycle for subagent activity items.

## Testing

- Cover concurrent item timing, repeated starts, turn-boundary cleanup, the
  missing-start fallback, subagent activity, and persisted web-search events.

GitOrigin-RevId: e7cec9c4f1ef6ba67f287e81fb4d7d856fcf87a7
This commit is contained in:
Owen Lin authored and copyberry committed 2026-07-25 16:06:54 +00:00
1 parent 3a08af44b2
commit af7f6f4d34
18 files changed
+183 -8

No files matched your search

@@ -46,9 +46,9 @@ pub(crate) async fn emit_sub_agent_activity(
turn: &crate::session::turn_context::TurnContext,
item: SubAgentActivityItem,
) {
session
.emit_turn_item_completed(turn, TurnItem::SubAgentActivity(item))
.await;
let item = TurnItem::SubAgentActivity(item);
session.emit_turn_item_started(turn, &item).await;
session.emit_turn_item_completed(turn, item).await;
}
pub(super) fn communication_from_tool_message(