Skip to content

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
hudson-worden:feat/missing-metrics-on-chatitem
Open

Fix Missing user message metrics (MetricsReport) due to early returns in _user_turn_completed_task and no initialization in on_end_of_turn#5437
hudson-worden wants to merge 2 commits intolivekit:mainfrom
hudson-worden:feat/missing-metrics-on-chatitem

Conversation

@hudson-worden
Copy link
Copy Markdown
Contributor

@hudson-worden hudson-worden commented Apr 13, 2026

There appears to be a few early returns where self._session._conversation_item_added(user_message) is called before adding available MetricsReport values to the chat item. info is available at the beginning of the function so there's no need to delay adding the related MetricsReport values. This ensures that the metrics are available in those early returns as well. The only caveat is that on_user_turn_completed_delay necessarily 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.

@hudson-worden hudson-worden force-pushed the feat/missing-metrics-on-chatitem branch from feeb83d to c1e6073 Compare April 13, 2026 20:11
@hudson-worden hudson-worden changed the title fix(agent_activity): enhance metrics reporting for user turn completion Fix Missing user message metrics (MetricsReport) due to early returns in _user_turn_completed_task Apr 13, 2026
@hudson-worden hudson-worden marked this pull request as ready for review April 13, 2026 20:15
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@hudson-worden hudson-worden changed the title Fix Missing user message metrics (MetricsReport) due to early returns in _user_turn_completed_task Fix Missing user message metrics (MetricsReport) due to early returns in _user_turn_completed_task and no initialization in on_end_of_turn Apr 13, 2026
@hudson-worden hudson-worden force-pushed the feat/missing-metrics-on-chatitem branch from 0c0b46a to 5807564 Compare April 14, 2026 14:00
…processing. refactor initialization into common function and use in 2 places.
@hudson-worden hudson-worden force-pushed the feat/missing-metrics-on-chatitem branch from 5807564 to 6a21070 Compare April 14, 2026 14:01
@hudson-worden
Copy link
Copy Markdown
Contributor Author

first commit moves the metricsreport initialization.
second commit extracts a common function and uses it where it was before and also in on_end_of_turn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant