feat(metrics): broadcast llm tps + ttfs - #2224
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 91f89f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bobronium
approved these changes
Aug 5, 2026
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.
Ports livekit/agents#6373 to expose per-turn LLM throughput and time-to-first-sentence metrics on assistant messages and preserve them across remote-session and telemetry serialization.
Adds a minor changeset for the new public
MetricsReportfields.Source diff coverage
7 source files classified
livekit-agents/livekit/agents/llm/chat_context.py->agents/src/llm/chat_context.ts. Added publicllmNodeTpsandllmNodeTtfsassistant-message metrics with equivalent semantics.livekit-agents/livekit/agents/voice/agent_activity.py->agents/src/voice/agent_activity.ts. Attaches TPS and TTFS to the committed assistant message.livekit-agents/livekit/agents/voice/generation.py->agents/src/voice/generation.ts. Records inference start, calculates TPS over the first-to-last content window using provider usage, captures only the explicit LiveKit TTS synthesis stamp for TTFS, and retains the existing fallback anchor for TTFB.livekit-agents/livekit/agents/voice/remote_session.py->agents/src/voice/remote_session.ts,agents/src/telemetry/traces.ts, andagents/src/telemetry/otel_http_exporter.ts. JS has explicit protobuf and cloud-log serialization boundaries rather than Python's allowed-key tuple, so both fields are mapped at each boundary and encoded as doubles.tests/test_agent_session.py->agents/src/voice/agent_session_metrics.test.ts. Uses the JS session/TTS harness to verify TTFS anchors on provider synthesis start and remains distinct from TTFB.tests/test_llm_node_metrics.py->agents/src/voice/generation_metrics.test.ts. Covers the same usage-present, zero-usage, no-usage, single-chunk, TTFT-exclusion, start-time, and TTFS omission cases.tests/test_session_host.py->agents/src/voice/remote_session.test.ts. Drives the JSSessionHostevent boundary and verifies both values reach protocolMetricsReport.Validation
pnpm test agents(1591 passed, 5 skipped)pnpm build:agentspnpm --filter @livekit/agents lint(passes with existing repository warnings)pnpm --filter @livekit/agents typecheckpnpm --filter @livekit/agents throws:checkcue-clivoice-mode runtime validation: assistant framework event includedllm_node_tpsandllm_node_ttfsapi:checkwas also attempted but is currently blocked before API comparison by API Extractor rejecting the repository's existing generatedexport * assyntax.Ported from livekit/agents#6373
Original PR description
llm_node_tps— output tokens/sec, from the provider's usage chunkllm_node_ttfs— inference start until the first sentence is handed off for synthesis (reuseslivekit.agents.types.USERDATA_TTS_STARTED_TIME)agent_false_interruption— the event, forwarded over the session hostwas implemented in #6691
Needs: livekit/protocol#1661 (released, already used)