Skip to content

feat(metrics): add playback_latency metric#5524

Merged
longcw merged 6 commits into
mainfrom
longc/audio-forwarding-metrics
Apr 27, 2026
Merged

feat(metrics): add playback_latency metric#5524
longcw merged 6 commits into
mainfrom
longc/audio-forwarding-metrics

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented Apr 22, 2026

Summary

Adds a new playback_latency metric on assistant ChatMessages, measuring the time between the first audio frame being forwarded and playback actually starting.

This metric is typically near-zero in normal pipelines, and becomes significant when a remote avatar worker is in the chain. Requires playback_started RPC call from the avatar to measure this latency #5511

@chenghao-mou chenghao-mou requested a review from a team April 22, 2026 08:47
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 3 additional findings.

Open in Devin Review

Typically very small; can be significant when a remote avatar worker is in the chain.

Assistant `ChatMessage` only
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense! Is it included inside the e2e_latency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, it's included inside the e2e_latency

Comment thread livekit-agents/livekit/agents/llm/chat_context.py Outdated
"""

playback_start_latency: float
"""Latency between the first audio frame being forwarded and playback starting on the client.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Latency between the first audio frame being forwarded and playback starting on the client

It isn't really accurate tho? We don't know when the client is playing the audio (+ network latency?)
It's true for avatars. But we should maybe clarify

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, it didn't include the network latency, updated the docstring.

@longcw longcw merged commit 1721618 into main Apr 27, 2026
23 checks passed
@longcw longcw deleted the longc/audio-forwarding-metrics branch April 27, 2026 06:37
Copy link
Copy Markdown
Contributor

This is an automated Claude Code Routine created by @toubatbrian. Right now it is in experimentation stage. The automation will start porting this PR into agents-js automatically.

Classification: core runtime improvement (new playback_latency metric on assistant ChatMessages in MetricsReport, plus tracking of started_forwarding_at in the audio forwarding task). No Python-specific dependencies — eligible for port.

Verified that no existing PR or branch in livekit/agents-js already ports this. Proceeding to port.


Generated by Claude Code

@longcw longcw changed the title feat(metrics): add playback_start_latency metric feat(metrics): add playback_latency metric Apr 27, 2026
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.

3 participants