mammoth-fountain-26720
12/19/2025, 3:22 PMtall-airline-16756
12/19/2025, 3:22 PMtall-airline-16756
12/19/2025, 3:22 PMAgentSession creation).
Root cause: you’re loading the Silero VAD model per session (silero.VAD.load() in the entrypoint), which can exhaust CPU/memory when multiple sessions start and push the worker above the load threshold.
What to do next (quick fixes):
1. Preload the VAD once per process and reuse it
• Use a prewarm/setup function (runs once per worker process) to call silero.VAD.load() and store the instance on the process userdata.
• In your entrypoint, pass the preloaded instance (e.g., ctx.proc.userdata["vad"]) to AgentSession instead of calling silero.VAD.load() there.
1. Restart the agent after changing code
• This clears any overloaded processes and ensures the prewarm runs.
Optional (self-hosted only): if your host can handle more concurrent load, you can raise the load threshold or implement a custom load_fnc. Note: LiveKit Cloud does not allow changing these values.
If you want, tell me:
• whether you’re running self-hosted or on LiveKit Cloud,
• a short snippet of your current entrypoint and where you call silero.VAD.load(),
and I’ll provide an exact code snippet tailored to your setup.
Sources: Silero VAD plugin | LiveKit docs | Agent server options | LiveKit docsmammoth-fountain-26720
12/19/2025, 3:27 PMBVCTelephony for best results
noise_cancellation=noise_cancellation.BVC(),
),
)
await session.say("Hey, how can I help you today?", allow_interruptions=True)tall-airline-16756
12/19/2025, 3:27 PMsilero.VAD.load() into a `prewarm`/setup function so the model is loaded once per process and stored on proc.userdata. In the entrypoint use that stored instance instead of calling .load().
Example (self-contained):
from livekit.agents import AgentServer, JobProcess, JobContext, AutoSubscribe
# import your other modules: silero, deepgram, openai, Agent, AgentSession, etc.
def prewarm(proc: JobProcess):
# load VAD once per worker process and store it
proc.userdata["vad"] = silero.VAD.load()
server = AgentServer(setup_fnc=prewarm) # ensure prewarm runs for each worker process
@server.rtc_session()
async def entrypoint(ctx: JobContext):
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
participant = await ctx.wait_for_participant()
<http://logger.info|logger.info>(f"starting voice assistant for participant {participant.identity}")
username = participant.identity or "PaulSmith"
system_instructions, vector_store_ids = get_system_instructions(username)
voice_instructions = "You are a voice agent. Ensure that your responses are short and concise.\n"
system_instructions = voice_instructions + system_instructions
# reuse preloaded VAD from the process userdata
vad_instance = ctx.proc.userdata.get("vad")
if vad_instance is None:
# fallback (should not happen if prewarm ran)
vad_instance = silero.VAD.load()
agent = Agent(
instructions=system_instructions,
vad=vad_instance,
stt=deepgram.STT(),
llm=openai.LLM.with_azure(
azure_deployment="gpt-4o",
model="gpt-4o",
azure_endpoint=AZURE_OPENAI_ENDPOINT,
api_key=AZURE_OPENAI_API_KEY,
api_version="2024-12-01-preview",
),
tts=openai.TTS.with_azure(
model="tts",
voice="nova",
api_version="2024-02-15-preview",
instructions="Speak slowly in a calm and soothing voice.",
),
)
session = AgentSession(userdata=MySessionInfo(user_name=username, vector_store_id=vector_store_ids[0]))
usage_collector = metrics.UsageCollector()
@session.on("metrics_collected")
def _on_metrics_collected(ev: MetricsCollectedEvent):
metrics.log_metrics(ev.metrics)
usage_collector.collect(ev.metrics)
async def log_usage():
summary = usage_collector.get_summary()
<http://logger.info|logger.info>(f"Usage: {summary}")
ctx.add_shutdown_callback(log_usage)
await session.start(
agent=agent,
room=ctx.room,
room_input_options=RoomInputOptions(noise_cancellation=noise_cancellation.BVC()),
)
await session.say("Hey, how can I help you today?", allow_interruptions=True)
Next steps:
• Apply this change and restart the agent processes so prewarm runs.
• If you still see capacity logs, tell me whether you run self-hosted or LiveKit Cloud and how many concurrent sessions you expect — I’ll suggest load tuning or further optimizations.mammoth-fountain-26720
12/19/2025, 3:33 PMtall-airline-16756
12/19/2025, 3:33 PMmammoth-fountain-26720
12/19/2025, 3:34 PMtall-airline-16756
12/19/2025, 3:35 PMproc.userdata["vad"] = silero.VAD.load().
• Confirm your entrypoint uses ctx.proc.userdata["vad"] (fallback only if missing).
• Restart/redeploy the agent so prewarm runs for each worker process.
Notes:
• You cannot change load_threshold on LiveKit Cloud; reducing per-process resource use (prewarm) is the right approach.
• If you still see "worker is at full capacity" logs after redeploy, please share the new logs (especially any repeated capacity lines) and I’ll help troubleshoot further.
Would you like me to review your updated code or new logs after you redeploy?
Sources: Silero VAD plugin | LiveKit docs | Agent server options | LiveKit docs | STT Metrics | LiveKit docs | Pipeline Translator Agent | LiveKit docs | Repeater | LiveKit docsmammoth-fountain-26720
12/19/2025, 3:35 PM