Fix Missing user message metrics (MetricsReport) due to early returns in _user_turn_completed_task and no initialization in on_end_of_turn#5437
Open
hudson-worden wants to merge 2 commits intolivekit:mainfrom
Conversation
feeb83d to
c1e6073
Compare
hudson-worden
commented
Apr 14, 2026
0c0b46a to
5807564
Compare
…processing. refactor initialization into common function and use in 2 places.
5807564 to
6a21070
Compare
Contributor
Author
|
first commit moves the metricsreport initialization. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There appears to be a few early returns where
self._session._conversation_item_added(user_message)is called before adding availableMetricsReportvalues to the chat item.infois available at the beginning of the function so there's no need to delay adding the relatedMetricsReportvalues. This ensures that the metrics are available in those early returns as well. The only caveat is thaton_user_turn_completed_delaynecessarily needs to wait until after it's computed which is why it's left where it is.Separately on_end_of_turn also is missing initialization of the metrics_report attribute even though it should have access to the same information, so I've added the attribute in that path as well.
The consequence is we're losing information that's already readily available.