Track compaction time in turn profiles (#34835)

## What changed

- Add `compaction_ms` to turn profile facts and turn analytics events.
- Measure manual and automatic compaction as an exclusive profile phase instead of including it in surrounding idle time.
- Complete the profile and total turn duration from the same instant so their elapsed times remain consistent.

## Testing

- Cover compaction phase accounting and profile-duration consistency.
- Update turn event serialization coverage for `compaction_ms`.

GitOrigin-RevId: 50f0e1cf19789a807f9f56c2ef763c620a5d641c
This commit is contained in:
Ben Romano authored and copyberry committed 2026-07-22 22:13:02 +00:00
1 parent 88f1cd9664
commit bd5b55e403
9 files changed
+114 -18

No files matched your search

+2
View File
@@ -2636,6 +2636,7 @@ fn codex_turn_event_params(
let TurnProfile {
before_first_sampling_ms,
sampling_ms,
compaction_ms,
between_sampling_overhead_ms,
tool_blocking_ms,
after_last_sampling_ms,
@@ -2708,6 +2709,7 @@ fn codex_turn_event_params(
.map(|token_usage| token_usage.total_tokens),
before_first_sampling_ms,
sampling_ms,
compaction_ms,
between_sampling_overhead_ms,
tool_blocking_ms,
after_last_sampling_ms,