Skip to content

fix: preserve LLM response telemetry on cancellation - #2048

Merged
toubatbrian merged 1 commit into
mainfrom
fix/2043-llm-response-telemetry
Jul 16, 2026
Merged

fix: preserve LLM response telemetry on cancellation#2048
toubatbrian merged 1 commit into
mainfrom
fix/2043-llm-response-telemetry

Conversation

@toubatbrian

@toubatbrian toubatbrian commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • finalize LLM response telemetry before stream cleanup so cancelled, failed, and preempted generations retain accumulated text and TTFT
  • record generated function calls on llm_node spans using the Python-compatible { id, call_id, name, arguments } wire shape
  • add normal-completion and AbortError regression coverage plus patch release metadata

Closes #2043.

Test plan

  • pnpm test -- --run agents/src/voice/generation_telemetry.test.ts (2 passed)
  • pnpm build
  • pnpm --filter @livekit/agents typecheck
  • changed-file ESLint (0 errors; 3 pre-existing TSDoc warnings in unchanged lines)
  • independent spec-compliance and code-quality reviews approved

Cue voice E2E

Exact head: c23ab516

  • sid_d83932e98ba4 — real LiveKit Inference providers (OpenAI GPT-4.1 mini, Deepgram Nova-3, Cartesia Sonic-3). Path-specific predicate debug_message(.payload.has_function_calls=true) resolved. The persisted event contains a getWeather call serialized with id, call_id, name, and JSON arguments.
  • sid_0562f88a1092 — real STT, TTS, and adaptive interruption with a deterministic slow streaming LLM boundary. Predicate overlapping_speech(.is_interruption=true) -> debug_message(.payload.controlled_stream_cancelled=true,.payload.response_text_length>0,.payload.has_ttft=true)[10s] resolved. The cancelled span retained 8,832 characters and TTFT; Cue also persisted the interrupted spoken prefix.
  • Artifacts: each session has manifest.json, events.jsonl, and per-command result.json/meta.json under ~/.cue-cli/sessions/<session>/. Both sessions were ended to flush artifacts. This Cue environment reported empty track maps, so it did not produce WAV files.

Finalize response attributes before stream cleanup so cancelled generations retain text, TTFT, and Python-compatible function calls.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian requested a review from a team as a code owner July 16, 2026 16:56
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c23ab51

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

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

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

Copy link
Copy Markdown
Contributor

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 bugs or issues to report.

Open in Devin Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c23ab516be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/src/voice/generation_telemetry.test.ts

@u9g u9g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@dtran26

dtran26 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Thank you!

@toubatbrian
toubatbrian merged commit 6300c1c into main Jul 16, 2026
9 checks passed
@toubatbrian
toubatbrian deleted the fix/2043-llm-response-telemetry branch July 16, 2026 17:31
@github-actions github-actions Bot mentioned this pull request Jul 16, 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.

llm_node response telemetry omits function calls and partial output on cancellation

3 participants