Repository navigation
fix(eval): time Live eval turns so invocation_duration_v1 is not n/a - #8472
Fruiterer333 wants to merge 2 commits into
Conversation
|
I checked this with the HEAD live-evaluation loop and single-turn helper in an offline harness. A final AI-assisted review; verification scope is described above. |
The foreground loop used `live_finished` to decide whether to record a turn's duration, but that event is also set when the session closes cleanly right after a final `turn_complete`, so a completed turn lost its duration. Record whether `turn_complete` was actually received for the current turn and use that to decide; a stream that ends mid-turn is still left untimed. Add regression tests for both EOF cases.
|
Thanks for running this so carefully, and for the exact three-way breakdown (completed turn / completed + clean EOF / mid-turn EOF) — that made the problem easy to see. You're right: I pushed a follow-up commit, fede1a2, instead of amending. There are two new regression cases (parametrized): |
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
In Live mode (
_generate_inferences_from_root_agent_live), eval never times its turns and callsconvert_events_to_eval_invocationswithout durations. Every LiveInvocationtherefore hasduration=None, andinvocation_duration_v1reports n/a per invocation and overall, while the same agent gets a duration for every turn on the regular path. The converter's docstring notes that durations can only be measured while the agent runs, so nothing downstream can recover them.Solution:
Time each Live turn and pass the durations to the converter, as the regular path does.
Design
time.monotonic(), rounded to milliseconds as on the regular path). The user simulator's turnaround stays outside the measurement, as on the regular path.None: in Live mode the model streams over one connection held open for the whole session, and the events are consumed by a background task started once per session (_LiveSession._consume_events). A per-turncollect_busy_intervals()cannot reach that task, and there is no per-turn model call to time, so reporting a split would mean inventing numbers._InvocationDurationV1Evaluatoralready handlesmodel_duration/tool_durationbeingNone.Out of scope: a time-to-first-response metric for voice agents, mentioned as possible follow-up in #8471.
Testing Plan
Unit Tests:
New test in
tests/unittests/evaluation/test_evaluation_generator.py(modelled ontest_records_a_duration_for_each_invocation):test_records_a_duration_for_each_live_invocation. It fails onmain(all durationsNone) and passes with the change.tests/unittests/evaluationpasses locally.Manual End-to-End (E2E) Tests:
Ran the offline repro from #8471 (fake Live connection that answers each turn after 0.2 s, no API key):
Checklist
Additional context
I used Grok Bot to help find the issue and draft the change; I reviewed the change, the repro output and the test results myself.