Baldwinzc baaf2bad47
fix(gateway): stamp turn_duration on last AI message only in /messages/page (#4755)
_enrich_thread_message_page inlined its own turn_duration loop that
stamped EVERY AI message of a run, re-introducing #4152 on the
/messages/page endpoint (the legacy /messages and /history endpoints
already route through stamp_turn_duration_on_last_ai after #4163, but
that fix missed the page path introduced earlier in #4065). A
multi-step turn thus rendered the same run lifetime beside every
intermediate AI message, reading as repeated thinking latency.

Replace the inline loop with the shared stamp_turn_duration_on_last_ai
helper so all three message endpoints agree: the run's wall-clock
duration lands on its final visible AI message only.
2026-08-11 22:00:57 +08:00
..