Skip to content

Prewarm LLM provider connections - #2106

Open
rosetta-livekit-bot[bot] wants to merge 4 commits into
mainfrom
port/prewarm-llm-connections
Open

Prewarm LLM provider connections#2106
rosetta-livekit-bot[bot] wants to merge 4 commits into
mainfrom
port/prewarm-llm-connections

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add idempotent, fire-and-forget LLM prewarming with cancellation and close cleanup
  • prewarm both the session-configured LLM and the resolved agent-level non-realtime LLM at activity startup
  • add provider prewarm implementations for LiveKit Inference, OpenAI, Anthropic, Google Gemini/Vertex, and Mistral
  • add deterministic lifecycle, activity-ordering, auth, request-shape, and cancellation coverage
  • retain patch changesets for the five directly touched release packages

Python parity

Compared against livekit/agents#6484 and the current Python implementation. JS now matches Python's session-level and activity-level prewarm lifecycle, including Agent.llm overrides, one-shot best-effort behavior, and provider model-list requests. RealtimeModel is excluded from the non-realtime hook, and FallbackAdapter remains intentionally unsupported as in Python.

The JS close lifecycle additionally aborts and awaits in-flight prewarm work and blocks starts after close.

Tests

  • strict red-green activity regression proves an agent-level LLM distinct from the session model prewarms exactly once before first inference
  • base lifecycle — 9 focused tests for no-op, swallowed rejection, one-shot failure, abort/wait, and close races
  • credential-free provider boundaries — Inference token refresh, OpenAI, Anthropic, real-SDK Google Gemini/Vertex auth, and Mistral request/cancellation paths
  • full agents suite — 110 files, 1,465 passed and 5 skipped
  • Anthropic — 12 passed
  • Google — 23 passed after final auth-boundary strengthening
  • Mistral — 1 passed, 3 skipped
  • OpenAI — 69 passed, 7 skipped
  • pnpm typecheck and pnpm build — passed
  • changed-file lint, Prettier, IDE diagnostics, and git diff --check — clean
  • independent final gates — Spec compliance: APPROVED and Code quality: APPROVED, no findings

API Extractor remains blocked only by documented base-branch namespace-export/missing-baseline issues; declaration builds pass and no new prewarm API warning is introduced.

Cue voice evidence

Fresh exact-head session: sid_915c77d73b3c

The agent-level LLM is distinct from the session LLM and sends a controlled models-list-compatible request to an in-process HTTP boundary. Persisted framework evidence proves:

  • exact head 795981ec09298f80618a0b4e035ade1228c9d97d
  • exactly one agent-level prewarm request
  • event sequence prewarm_request,chat
  • resolved predicate agent-prewarm-once-before-chat
  • same command reached speaking and persisted the assistant reply
  • session and command WAVs are stereo 48 kHz with non-zero samples on both channels

The controlled endpoint proves framework ordering/count and lifecycle dispatch; it does not claim production-provider latency magnitude or TLS reuse.


Ported from livekit/agents#6484

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from a team as a code owner July 24, 2026 05:56
@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 795981e

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

This PR includes changesets to release 39 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-anam 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-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp 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-neuphonic Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface 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

@rosetta-livekit-bot
rosetta-livekit-bot Bot requested a review from davidzhao July 24, 2026 05:57

@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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

toubatbrian and others added 3 commits July 24, 2026 14:13
Prewarm resolved agent-level models and guard close races, with deterministic lifecycle and provider-boundary coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise the installed SDK through token and network boundaries so auth ordering and cancellation cannot be hidden by a full-client mock.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian

Copy link
Copy Markdown
Contributor

Completed Rosetta parity and verification at exact head 795981ec09298f80618a0b4e035ade1228c9d97d.

The resolved branch adds the missing agent-level activity prewarm path, close-race protection, deterministic base/provider coverage including real-SDK Vertex auth, and fresh Cue voice evidence sid_915c77d73b3c proving one controlled prewarm request before first chat with distinct session/agent LLMs. Full focused/provider/agents tests, typecheck, build, formatting, lint, stereo WAV checks, independent spec/quality review, and exact-head CI are green. Zero unresolved threads; mergeable.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant