rich-application-94483
05/14/2026, 3:47 PMMultiLingual() turn detection, and that is loaded fresh each time an agent session is created, and can add some load since it's a large model to load/initialize each session. I was wondering if there's any reason to not load this in the prewarm section to be available for all agents and cached similarly to how we prewarm Scelario for VAD?tall-airline-16756
05/14/2026, 3:47 PMtall-airline-16756
05/14/2026, 3:48 PMMultiLingual() the same way you prewarm Silero VAD. Preloading it in your prewarm function makes the model available to all agent sessions, removes the per-session load cost, and reduces time-to-first-audio. The model runs on CPU, uses under ~500 MB RAM, and requires the model files be downloaded once (use uv run agent.py download-files).
If you'd like, I can:
• Provide the exact prewarm+session snippet for your current agent code, or
• Suggest memory/CPU sizing guidance for your deployment.
Which would help most?
Sources: LiveKit turn detector plugin | LiveKit Documentation | Server options | LiveKit Documentation | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Silero VAD plugin | LiveKit Documentation | Understand and Improve Agent Latency | LiveKit, with interactive elementsrich-application-94483
05/14/2026, 7:18 PMtall-airline-16756
05/14/2026, 7:19 PMprewarm (server setup) create and store the model on proc.userdata alongside VAD:
from livekit.plugins.turn_detector.multilingual import MultilingualModel
def prewarm(proc: JobProcess):
proc.userdata["vad"] = silero.VAD.load()
proc.userdata["turn_detector"] = MultilingualModel()
server.setup_fnc = prewarm
1. In each session entrypoint, pull the prewarmed instance from ctx.proc.userdata and pass it to your AgentSession:
@server.rtc_session(agent_name="my-agent")
async def entrypoint(ctx: JobContext):
turn_detector = ctx.proc.userdata["turn_detector"]
vad = ctx.proc.userdata["vad"]
session = AgentSession(turn_detection=turn_detector, vad=vad, ...)
1. Ensure model weights are downloaded beforehand (e.g., uv run agent.py download-files).
If your current Multilingual initializer truly requires a JobContext (custom wrapper or additional per-job state), you can:
• Prewarm the raw MultilingualModel and wrap it per-session with a lightweight adapter that uses the JobContext only to set per-session config (not to reload weights).
• Or lazily initialize a tiny per-job wrapper that references the shared model instance on first use.
Would you like a small adapter example for the per-session wrapper based on your current AgentSession code?
Sources: LiveKit turn detector plugin | LiveKit Documentation | Build a multilingual voice agent that automatically switches languages | Li... | Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | Improved end-of-turn model cuts Voice AI interruptions 39% | LiveKit | How to Build a Background Observer for Voice AI Guardrails | LiveKit, with interactive elementsrich-application-94483
05/14/2026, 7:22 PMTraceback (most recent call last):\n File \"/app/.venv/lib/python3.13/site-packages/livekit/agents/ipc/proc_pool.py\", line 209, in _proc_spawn_task\n await proc.initialize()\n File \"/app/.venv/lib/python3.13/site-packages/livekit/agents/ipc/supervised_proc.py\", line 247, in initialize\n raise RuntimeError(f\"process initialization failed: {init_res.error}\")\nRuntimeError: process initialization failed: no job context found, are you running this code inside a job entrypoint?tall-airline-16756
05/14/2026, 7:23 PMctx, ctx.job, ctx.room, etc. will raise "no job context found."
What to do
• Prewarm only the heavy, context‑free model (the MultilingualModel) and store it on proc.userdata.
• Instantiate any wrapper that requires job-specific information (the Multilingual helper that needs a JobContext) inside your entrypoint using the prewarmed model.
• If your helper doesn't accept a prewarmed model instance, create a thin per-job adapter that wraps the shared model and adds job-specific state.
Minimal pattern
1. Prewarm:
def prewarm(proc: JobProcess):
proc.userdata["multilingual_model"] = MultilingualModel()
proc.userdata["vad"] = silero.VAD.load()
server.setup_fnc = prewarm
1. Entrypoint:
async def entrypoint(ctx: JobContext):
model = ctx.proc.userdata["multilingual_model"]
# wrap/build the job-scoped detector here
turn_detector = Multilingual(model=model, job=ctx.job) # or use a small adapter
session = AgentSession(turn_detection=turn_detector, vad=ctx.proc.userdata["vad"], ...)
If you want, share the exact Multilingual/initializer code you're calling and I’ll show the exact adapter or single-line change to avoid the JobContext access during prewarm.
Sources: LiveKit turn detector plugin | LiveKit Documentation | Server options | LiveKit Documentation | Silero VAD plugin | LiveKit Documentation, with interactive elementsrich-application-94483
05/14/2026, 7:31 PMfrom livekit.plugins.turn_detector.multilingual import MultilingualModel
2. prewarm
proc.userdata["turn_detector"] = MultilingualModel()
3. build
def _build_turn_handling(turn_detector: MultilingualModel) -> TurnHandlingOptions:
return TurnHandlingOptions(
turn_detection=turn_detector,
endpointing=ENDPOINTING_CONFIG,
interruption=INTERRUPTION_CONFIG,
preemptive_generation={"enabled": True},
)
4. session
turn_handling=_build_turn_handling(ctx.proc.userdata["turn_detector"]),tall-airline-16756
05/14/2026, 7:31 PMMultilingualModel where the per-job Multilingual wrapper (or whatever class implements the turn-detector interface) is expected — and that wrapper requires a JobContext during construction. Prewarm can only create context-free objects (the raw model weights), not job-scoped wrappers.
Fix (minimal, safe pattern)
1. Prewarm the raw model (no JobContext):
from livekit.plugins.turn_detector.multilingual import MultilingualModel
def prewarm(proc: JobProcess):
proc.userdata["turn_detector_model"] = MultilingualModel()
proc.userdata["vad"] = silero.VAD.load()
server.setup_fnc = prewarm
1. In the entrypoint, build the job-scoped wrapper that needs JobContext, then pass that into TurnHandlingOptions:
from livekit.plugins.turn_detector.multilingual import Multilingual # wrapper that needs ctx/job
@server.rtc_session(agent_name="my-agent")
async def entrypoint(ctx: JobContext):
model = ctx.proc.userdata["turn_detector_model"]
# create the per-job detector that can access JobContext
job_turn_detector = Multilingual(model=model, job=ctx.job) # or Multilingual(ctx, model=model) depending on API
turn_handling = _build_turn_handling(job_turn_detector)
session = AgentSession(turn_handling=turn_handling, vad=ctx.proc.userdata["vad"], ...)
Alternative if the wrapper API won’t accept an injected model
• Prewarm only the model weights to disk (download-files), then construct the full Multilingual instance inside the entrypoint (it will load from local weights quickly).
• Or create a tiny adapter class that accepts the shared MultilingualModel and implements the per-job methods by using ctx for job-specific behavior.
If you share which Multilingual constructor signature you have (what args it expects), I’ll give the exact one-line wrapper or adapter to use.
, with interactive elements