why am I getting an error ``` vad=ct...
# ask-ai
a
why am I getting an error
Copy code
vad=ctx.proc.userdata["vad"],                                                                                       
                                                   ~~~~~~~~~~~~~~~~~^^^^^^^                                                                                        
                                           KeyError: 'vad'
Copy code
server = AgentServer()

def prewarm(proc: JobProcess):
    <http://logger.info|logger.info>("Prewarming VAD model...")
    proc.userdata["vad"] = silero.VAD.load()

server.setup_fnc=prewarm

@server.rtc_session(agent_name='general-assistant-agent')
async def entrypoint(ctx: JobContext):
    <http://logger.info|logger.info>(
        "Agent entrypoint called for room: %s",
        ctx.job.room.name if ctx.job.room else "unknown",
    )

    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
    <http://logger.info|logger.info>("Connected to room: %s", ctx.room.name)

    session = AgentSession(
        stt=openai.STT(model="gpt-4o-transcribe"),
        llm=openai.LLM(model="gpt-4.1"),
        tts=elevenlabs.TTS(model="eleven_multilingual_v2"),
        vad=ctx.proc.userdata["vad"],
        turn_detection=MultilingualModel(),
        preemptive_generation=True,
        user_away_timeout=10.0
    )

    await session.start(
        agent=TestAgent(),
        room=ctx.room,
    )

if __name__ == "__main__":
    cli.run_app(server)
t
Thanks for reaching out, Ahron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that KeyError means
ctx.proc.userdata["vad"]
wasn’t set when your entrypoint ran. You’re accessing the VAD before it’s guaranteed to exist. What’s happening (brief): • Your
prewarm
stores the VAD at
proc.userdata["vad"]
when it runs. • If the process starts without
prewarm
running (misconfigured, not hooked up, or not completed yet),
userdata["vad"]
won’t exist and you get KeyError. What you can do right now (practical steps): 1. Verify
prewarm
is actually registered and runs before sessions start ◦ Confirm
server.setup_fnc = prewarm
is executed in the same process that runs the entrypoint. ◦ Ensure the process lifecycle triggers
setup_fnc
before any
rtc_session
handlers execute. 1. Add a guard in your entrypoint so the error is clearer and handled gracefully:
Copy code
@server.rtc_session(agent_name='general-assistant-agent')
async def entrypoint(ctx: JobContext):
    if "vad" not in ctx.proc.userdata:
        logger.error("VAD model not found in userdata. Ensure prewarm is set and completed.")
        raise RuntimeError("VAD model not loaded")

    vad_instance = ctx.proc.userdata["vad"]
    ...
1. Optionally lazily load if setup timing is uncertain ◦ Load the model on-demand the first time it’s needed and store it back to `proc.userdata`:
Copy code
if "vad" not in ctx.proc.userdata:
    ctx.proc.userdata["vad"] = silero.VAD.load()
vad_instance = ctx.proc.userdata["vad"]
• This avoids relying on
prewarm
but may add a short delay the first time. If you’d like, tell me: • Whether
prewarm
is running in the same process as the entrypoint, or • How you start the server (CLI flags or deployment setup), and I’ll help you confirm the correct lifecycle ordering or suggest the best place to load the model. Sources: Silero VAD plugin | LiveKit Documentation | Server options | LiveKit Documentation
a
why isn't the prewarm not working in the code provided?
t
Thanks — I can help figure out why
prewarm
isn’t running. You’re right to focus on that, since if
prewarm
never executes in the same process as your entrypoint,
proc.userdata["vad"]
will be missing and raise the KeyError. A few likely causes and targeted checks you can run right now: 1) Confirm
server.setup_fnc = prewarm
runs in the same process • Add a log at module import time and inside
prewarm
to verify both are executed in the same process that later handles the rtc session. • Example logs to add: ◦ At top-level: logger.info("Starting server in PID %s", os.getpid()) ◦ Inside prewarm: logger.info("prewarm running in PID %s — loading VAD", os.getpid()) 2) Ensure the server lifecycle actually calls
setup_fnc
before handling sessions • Some runtimes call setup once per worker process; if your entrypoint is triggered in a different worker or before setup finishes, userdata won’t be set. • Confirm your server framework’s docs or logs show setup execution before rtc sessions start. 3) Check for exceptions inside prewarm • If
silero.VAD.load()
raises an exception,
proc.userdata["vad"]
will never be set. • Wrap the load in try/except and log any exception:
Copy code
def prewarm(proc: JobProcess):
    try:
        <http://logger.info|logger.info>("Prewarming VAD model...")
        proc.userdata["vad"] = silero.VAD.load()
        <http://logger.info|logger.info>("VAD loaded successfully")
    except Exception as e:
        logger.exception("Failed to load VAD in prewarm: %s", e)
        raise
4) Verify
proc
identity and userdata store • Log the
proc
object (or its id) in both prewarm and entrypoint to ensure
ctx.proc
is the same process object that prewarm used. • If they differ, you’re looking at a multi-process or multi-worker setup where prewarm ran in one process and entrypoint is running in another. 5) Race condition: prewarm not finished before entrypoint runs • If your server starts sessions immediately, there could be a timing issue. Add a readiness flag in
proc.userdata
, or block entry until VAD exists:
Copy code
# in prewarm
proc.userdata["vad_ready"] = False
proc.userdata["vad"] = silero.VAD.load()
proc.userdata["vad_ready"] = True

# in entrypoint
if not ctx.proc.userdata.get("vad_ready"):
    raise RuntimeError("VAD not ready yet")
• Or lazily load in entrypoint if acceptable (will add first-call delay). 6) Deployment differences (local vs container vs orchestrator) • If you run multiple containers or worker processes, ensure each one calls
prewarm
or performs its own load. Prewarm runs once per process, not globally across multiple processes. Next, to narrow it down quickly, please tell me: • How you start the server (the exact CLI command or deployment setup). • Whether you see the “Prewarming VAD model…” log line in your logs. If not, paste any startup logs around that time. • Whether you run multiple workers/containers or a single process. With those details I’ll point to the specific fix (ensure setup runs in each worker, add logging/failsafe, or change to lazy load).
a
I don't see the prewarm log in the logs. I run the dev env.
t
Thanks for confirming — because you don’t see the prewarm log, prewarm never ran in the process that handled your entrypoint. Let’s walk through quick, focused checks to find why and fix it. What to check right now (in order) 1) Confirm assignment order • Ensure
prewarm
is defined first and then assigned to the server:
server.setup_fnc = prewarm
. This assignment must happen before you call
cli.run_app(server)
. 2) Ensure the server lifecycle is running • Verify you call
cli.run_app(server)
in the same module where
server.setup_fnc
is set. If
cli.run_app(server)
is not reached (or run from a different module), setup won’t run. 3) Add explicit logs and a PID to verify process • Add logging at module import, inside prewarm, and in entrypoint to confirm which process runs them:
Copy code
import os
<http://logger.info|logger.info>("Starting server module in PID %s", os.getpid())

def prewarm(proc: JobProcess):
    <http://logger.info|logger.info>("prewarm running in PID %s — prewarming VAD", os.getpid())
    proc.userdata["vad"] = silero.VAD.load()
    <http://logger.info|logger.info>("VAD loaded in PID %s", os.getpid())
• If you still don’t see the prewarm message, the function is not being called in this process. 4) Check for exceptions inside prewarm • Wrap the load to catch and log exceptions so a silent failure doesn’t hide the fact prewarm ran:
Copy code
try:
    proc.userdata["vad"] = silero.VAD.load()
except Exception:
    logger.exception("Failed to load VAD in prewarm")
    raise
5) Single-process dev behavior vs multiple workers • In dev mode you usually run a single process, but verify you are not starting multiple worker processes or containers. Prewarm runs once per process; if your entrypoint executes in a different process than prewarm, userdata won’t be shared. 6) Quick fallback while debugging • To unblock quickly, lazily load the VAD in entrypoint if it’s missing:
Copy code
if "vad" not in ctx.proc.userdata:
    <http://logger.info|logger.info>("VAD not found in userdata — loading lazily")
    ctx.proc.userdata["vad"] = silero.VAD.load()
vad_instance = ctx.proc.userdata["vad"]
• This avoids waiting on setup lifecycle while you diagnose why prewarm didn’t run. If you want, next I can help you pinpoint the root cause — please share: • The exact command you run to start the dev server (CLI command). • The top ~30 lines of startup logs (particularly around when the process starts). • Whether you run with any worker/auto-reload or container orchestration (e.g., uvicorn reload, Docker, or a process manager). With those, I’ll tell you the precise step to ensure prewarm runs in the same process as your entrypoint. Sources: Server options | LiveKit Documentation | Server startup modes | LiveKit Documentation
a
Copy code
error running inference
Traceback (most recent call last):
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/ipc/inference_proc_lazy_main.py", line 103, in _handle_inference_request
    data = await loop.run_in_executor(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self._executor, self._runners[msg.method].run, msg.data
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/base.py", line 159, in run
    text = self._format_chat_ctx(chat_ctx)
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/base.py", line 86, in _format_chat_ctx
    convo_text = self._tokenizer.apply_chat_template(
                 ^^^^^^^^^^^^^^^
AttributeError: '_EUORunnerMultilingual' object has no attribute '_tokenizer'
    01:21:05.533 DEBUG  livekit.agents     http_session(): creating a new httpclient ctx  
                                         {"pid": 3997214, "job_id": "AJ_8438RzvGdqxw", "room_id": "RM_vSZaGfM7T9PN"}
    01:21:05.548 ERROR  livekit.agents     Error predicting end of turn                                                                                            
                                           Traceback (most recent call last):                                                                                      
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/voice/audio_recognition.py", line 537,    
                                           in _bounce_eou_task                                                                                                     
                                               end_of_turn_probability = await turn_detector.predict_end_of_turn(                                                  
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                  
                                                   chat_ctx                                                                                                        
                                                   ^^^^^^^^                                                                                                        
                                               )                                                                                                                   
                                               ^                                                                                                                   
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/multilingual.py", line     
                                           70, in predict_end_of_turn                                                                                              
                                               return await super().predict_end_of_turn(chat_ctx, timeout=timeout)                                                 
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                 
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/base.py", line 288, in     
                                           predict_end_of_turn                                                                                                     
                                               result = await asyncio.wait_for(                                                                                    
                                                        ^^^^^^^^^^^^^^^^^^^^^^^                                                                                    
                                                   self._executor.do_inference(self._inference_method(), json_data), timeout=timeout                               
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                               
                                               )                                                                                                                   
                                               ^                                                                                                                   
                                             File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for                                              
                                               return await fut                                                                                                    
                                                      ^^^^^^^^^                                                                                                    
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/ipc/job_proc_lazy_main.py", line 143, in  
                                           do_inference                                                                                                            
                                               raise RuntimeError(f"inference of {method} failed: {inf_resp.error}")                                               
                                           RuntimeError: inference of lk_end_of_utterance_multilingual failed: inference of lk_end_of_utterance_multilingual       
                                           failed: '_EUORunnerMultilingual' object has no attribute '_tokenizer'                                                   
                                         {"pid": 3997214, "job_id": "AJ_8438RzvGdqxw", "room_id": "RM_vSZaGfM7T9PN"}
Traceback (most recent call last):
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/voice/audio_recognition.py", line 537, in _bounce_eou_task
    end_of_turn_probability = await turn_detector.predict_end_of_turn(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        chat_ctx
        ^^^^^^^^
    )
    ^
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/multilingual.py", line 70, in predict_end_of_turn
    return await super().predict_end_of_turn(chat_ctx, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/base.py", line 288, in predict_end_of_turn
    result = await asyncio.wait_for(
             ^^^^^^^^^^^^^^^^^^^^^^^
        self._executor.do_inference(self._inference_method(), json_data), timeout=timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for
    return await fut
           ^^^^^^^^^
  File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/ipc/job_proc_lazy_main.py", line 143, in do_inference
    raise RuntimeError(f"inference of {method} failed: {inf_resp.error}")
RuntimeError: inference of lk_end_of_utterance_multilingual failed: inference of lk_end_of_utterance_multilingual failed: '_EUORunnerMultilingual' object has no 
attribute '_tokenizer'
t
Thanks — this is very helpful detail. You’re seeing two related but distinct problems: (A)
prewarm
never ran in the process that handled your session (so
vad
was missing earlier), and (B) the turn-detector inference failed because the runner object wasn’t fully initialized (
_tokenizer
missing). Both are runtime/process-initialization issues; here’s a focused plan to diagnose and fix them. Quick summary of what’s happening • The missing prewarm log means the
prewarm
function isn’t being executed in the same process that handles rtc sessions. Prewarm runs once per process and must be registered and invoked before sessions start. • The
_tokenizer
AttributeError shows the multilingual turn-detector runner didn’t initialize correctly (tokenizer not created). That typically means the model/tokenizer files are absent/corrupted, failed to download, or initialization was interrupted in that process. Immediate checks (do these first) 1. Confirm setup assignment happens before server start ◦ Ensure you set
server.setup_fnc = prewarm
after defining
prewarm
and before calling
cli.run_app(server)
. 1. Add explicit logs to prove invocation and process identity ◦ Put these logs in module top-level,
prewarm
, and `entrypoint`: ▪︎ Module start: logger.info("server module start pid=%s", os.getpid()) ▪︎ In prewarm: logger.info("prewarm pid=%s: loading VAD", os.getpid()) ▪︎ In entrypoint: logger.info("entrypoint pid=%s", os.getpid()) ◦ If you never see the prewarm log, the function isn’t being invoked in that process. If prewarm still doesn’t run, determine process topology • Are you running a single dev process or something that spawns workers (auto-reload, multiple processes, Docker with multiple replicas)? • Prewarm runs per process. If entrypoint is served by a different worker process, that worker also needs prewarm or lazy load. Fixes for prewarm not running • Ensure assignment and start order: ◦ Define
prewarm(proc)
then set
server.setup_fnc = prewarm
and then call
cli.run_app(server)
in the same file/process. • If dev auto-reload spawns child processes, ensure those children also run setup or disable reload while debugging. • As a safe fallback during debugging, lazily load the VAD in entrypoint if missing:
Copy code
if "vad" not in ctx.proc.userdata:
    <http://logger.info|logger.info>("VAD not in userdata — loading lazily in entrypoint")
    ctx.proc.userdata["vad"] = silero.VAD.load()
vad_instance = ctx.proc.userdata["vad"]
This unblocks you while you fix process lifecycle. Diagnosing and fixing the
_tokenizer
AttributeError What it means: • The inference runner
_EUORunnerMultilingual
is missing
_tokenizer
. That indicates the multilingual turn-detector model or tokenizer didn’t initialize fully in that process when inference was requested. Steps to resolve: 1. Re-download model artifacts ◦ Run the project’s model-download task so files are present before runtime. (You mentioned dev — run whatever download command your repo provides to fetch HF models.) ◦ Example: run the repository’s download script/command so the files land in the HF cache used by the process. 1. Verify model files exist and are complete ◦ Check the Hugging Face cache (default:
~/.cache/huggingface/hub
or the path in
HF_HUB_CACHE
) for the turn-detector model snapshot. ◦ Confirm presence of
config.json
, model weights (
pytorch_model.bin
or similar), and tokenizer files (
tokenizer.json
,
vocab*
). 1. Check for exceptions during model init ◦ Add try/except and logging inside the model initialization that creates the multilingual runner so any failures are visible (e.g., disk permission, OOM, corrupted file). ◦ Example:
Copy code
try:
    model = MultilingualModel()
    <http://logger.info|logger.info>("MultilingualModel initialized")
except Exception:
    logger.exception("MultilingualModel failed to initialize")
    raise
1. Confirm dependencies and environment ◦ Ensure compatible
transformers
,
torch
, and
livekit-agents
versions are installed in the same Python environment the process uses. ◦ Check disk space and network connectivity — the process must be able to read the cache or download files. 1. Pre-download in container/build time (if using containers) ◦ If you run inside Docker or an isolated environment, download the model during image build so runtime processes won’t try to fetch it (avoids network/permission issues at runtime). 1. Test model loading in a simple script ◦ Run a small standalone script in the same environment/process to instantiate the MultilingualModel — this isolates agent lifecycle issues:
Copy code
from livekit.plugins.turn_detector.multilingual import MultilingualModel
m = MultilingualModel()
print("loaded")
If that script raises errors, the problem is model/dependency/environment, not the agent orchestration. Putting it together — a short checklist to run now 1. Add PID and prewarm logs; restart dev server and look for prewarm log. 2. If prewarm still absent, verify
server.setup_fnc = prewarm
is executed in same module/process before
cli.run_app(server)
. 3. If prewarm logged but
_tokenizer
error persists: re-download model artifacts, verify files, and add logging around model init. 4. As a temporary unblock, lazily load VAD in entrypoint and ensure the turn-detector model is pre-downloaded. If you want, I can help further — please share the answers to these: • Exact command you run to start the dev server (copy-paste). • The startup logs (first ~50 lines) showing the server module start and any prewarm logs (if present). • pip list or the relevant package versions for
livekit-agents
,
transformers
, and
torch
. With those I’ll point to the precise fix (order of operations, environment variable, or download step) to get both prewarm and the turn-detector initialized cleanly.
a
it's a new error I got
Copy code
01:33:43.086 ERROR  livekit.agents     Error predicting end of turn                                                                                            
                                           Traceback (most recent call last):                                                                                      
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/agents/voice/audio_recognition.py", line 537,    
                                           in _bounce_eou_task                                                                                                     
                                               end_of_turn_probability = await turn_detector.predict_end_of_turn(                                                  
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                  
                                                   chat_ctx                                                                                                        
                                                   ^^^^^^^^                                                                                                        
                                               )                                                                                                                   
                                               ^                                                                                                                   
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/multilingual.py", line     
                                           70, in predict_end_of_turn                                                                                              
                                               return await super().predict_end_of_turn(chat_ctx, timeout=timeout)                                                 
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                 
                                             File "/var/www/livekit-agent/lk/lib/python3.13/site-packages/livekit/plugins/turn_detector/base.py", line 291, in     
                                           predict_end_of_turn                                                                                                     
                                               assert result is not None, "end_of_utterance prediction should always returns a result"                             
                                                      ^^^^^^^^^^^^^^^^^^                                                                                           
                                           AssertionError: end_of_utterance prediction should always returns a result                                              
                                         {"pid": 3999833, "job_id": "AJ_pMSLX4mmfDya", "room_id": "RM_i6Cgv2TaM4Jp"}
t
Thanks — that new error shows the turn-detector inference returned no result. I’ll explain what that means and give a focused checklist to diagnose and fix it quickly. What the error means • The assertion
end_of_utterance prediction should always returns a result
fired because the turn-detector inference returned
None
instead of a numeric prediction. • That typically happens when the model inference failed or timed out internally (not a downstream logic bug). Common causes: model files missing/corrupted, the model failed to initialize, or the process lacked CPU resources and the inference stalled. Immediate checklist to run now 1. Confirm model files exist ◦ Verify the multilingual turn-detector model snapshot and tokenizer are present in your Hugging Face cache (default:
~/.cache/huggingface/hub
or the path in
HF_HUB_CACHE
). ◦ Look for
config.json
, model weights (e.g.,
pytorch_model.bin
), and tokenizer files (
tokenizer.json
,
vocab*
). 1. Re-download the model artifacts ◦ Run your repo’s download task so the files are guaranteed present before runtime (example: the project’s download command or script). This avoids runtime download failures. ◦ After re-downloading, restart the dev server and watch logs for successful model initialization. 1. Add logging around model init and inference ◦ Log success/failure when the multilingual turn detector is constructed and when inference starts/ends. Capture exceptions and stack traces:
Copy code
try:
    model = MultilingualModel()
    <http://logger.info|logger.info>("MultilingualModel initialized in pid=%s", os.getpid())
except Exception:
    logger.exception("Failed to initialize MultilingualModel")
    raise
• If initialization fails, the logs will show why instead of returning None. 1. Test model loading outside the agent ◦ Run a tiny script in the same environment:
Copy code
from livekit.plugins.turn_detector.multilingual import MultilingualModel
m = MultilingualModel()
print("loaded")
• If this fails, the issue is model/dependency/environment, not agent orchestration. 1. Check resource constraints (very likely if on burstable instances) ◦ If you run on burstable AWS instances (t3/t4g), CPU credits can be exhausted and cause big slowdowns. The turn detector needs stable CPU for timely inference. ◦ Monitor CPU usage and CPUCreditBalance in CloudWatch. If credits are low or CPU is throttled, inference may stall/timeout and return None. ◦ Recommended fix: use a non-burstable instance type (compute-optimized or general purpose such as
c6i
or
m5
) or increase instance size. 1. Ensure correct dependencies and environment ◦ Confirm
transformers
,
torch
, and
livekit-agents
versions are compatible in the same Python environment the process uses. ◦ Verify there’s enough RAM and disk space and that the process can read the HF cache. 1. Consider increasing inference timeout while debugging ◦ The turn detector expects short latencies (50–160ms). Temporarily increasing timeout can help confirm whether slow inference (not absolute failure) is the cause. Quick triage questions for you • Are you running on an AWS burstable instance (t3/t4g)? If so, which instance type? • Can you paste startup logs (first ~50 lines) and any logs around model initialization? • Can you run the standalone MultilingualModel test script above in the same environment and share its output or error? If you share those details I’ll point to the most likely fix (re-download model, switch instance type, or adjust environment) and provide exact commands to run. Sources: LiveKit turn detector plugin | LiveKit Documentation | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS
a
Copy code
python3 agents.py download-files
    01:38:29.995 INFO   livekit.agents     Downloading files for livekit.plugins.openai  
    01:38:29.998 INFO   livekit.agents     Finished downloading files for livekit.plugins.openai  
    01:38:30.000 INFO   livekit.agents     Downloading files for livekit.plugins.silero  
    01:38:30.008 INFO   livekit.agents     Finished downloading files for livekit.plugins.silero  
    01:38:30.009 INFO   livekit.agents     Downloading files for livekit.plugins.elevenlabs  
    01:38:30.011 INFO   livekit.agents     Finished downloading files for livekit.plugins.elevenlabs  
    01:38:30.026 INFO   livekit.agents     Downloading files for livekit.plugins.turn_detector  
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
    01:38:38.843 INFO   livekit.agents     Finished downloading files for livekit.plugins.turn_detector
t
Thanks — that download output is the smoking gun. What happened • The download step completed for each plugin, but the turn-detector download logged: "None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used." • That means deep-learning runtimes are missing in the environment, so the turn-detector model weights and tokenizer that require a framework (PyTorch/TensorFlow/Flax) were not downloaded/usable. • Without those model files available and a proper runtime, the multilingual runner can fail to initialize or produce results (it can return None), which explains the AssertionError you saw. What to do next (step-by-step) 1) Install a supported runtime (pick one) • If you want CPU-only PyTorch (simplest): ◦ pip install torch --index-url https://download.pytorch.org/whl/cpu • If you have a GPU and want CUDA-accelerated PyTorch, install the matching torch package for your CUDA version from PyTorch’s instructions. • Alternative frameworks (less common here): TensorFlow >= 2.0 or Flax can work, but LiveKit examples generally use PyTorch. 2) Verify the runtime is visible to Python • Quick check: ◦ python -c "import torch; print(torch.version)" • If this errors, the runtime isn’t installed correctly. 3) Re-run the repository download step • After installing PyTorch/TensorFlow/Flax, run: ◦ python3 agents.py download-files • Confirm the turn_detector download no longer prints the "None of PyTorch..." message and that it finishes successfully. 4) Restart your dev server and watch logs • Start the agent and look for logs indicating the turn detector model initialized successfully. Also confirm your
prewarm
logs appear (if you added them earlier). 5) Re-test the scenario that triggered the error • The turn-detector inference should now return a numeric result rather than None. If inference is slow or times out, see step 7 below. Optional / helpful checks • Check that model files are present in HF cache after download: ◦ ~/.cache/huggingface/hub (or path in HF_HUB_CACHE) ◦ Look for a snapshot folder containing model weights and tokenizer files. • Test model init in an isolated script: ◦ python -c "from livekit.plugins.turn_detector.multilingual import MultilingualModel; m=MultilingualModel(); print('ok')" ◦ This will surface initialization errors directly. If inference still fails after installing a framework • Resource throttling: if you’re on a burstable instance (t3/t4g), CPU exhaustion can cause inference to stall/timeout and return None — consider using a non-burstable CPU type or larger instance. • Dependency mismatch: ensure compatible versions of transformers, torch, and livekit-agents are installed. Tell me these three small details and I’ll give exact install commands for your environment • OS and packaging environment (Linux distro? virtualenv? pipenv? conda?) • Python version (python3 --version) • Do you want CPU-only or GPU (CUDA) PyTorch? I’ll respond with the precise pip/conda commands and next verification steps once you share that.