why can't i define turndetection as well in the pr...
# ask-ai
s
why can't i define turndetection as well in the prewarm function
t
Thanks for reaching out, Ayush. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're right to ask — regarding defining
turn_detection
in `prewarm`: that won't reliably work. Prewarm is for loading heavy, session‑independent resources (e.g., VAD models) into
proc.userdata
. Turn detection models are session‑level: they depend on runtime session configuration, an active STT stream, and session lifecycle hooks that aren't available during
prewarm
. The turn detector also may not safely accept a model instance serialized from prewarm into the session. What you can do instead: • Use
prewarm
to load reusable assets (VAD, shared weights) and store them in
proc.userdata
. • Instantiate the turn detection model (for example
MultilingualModel
or
EnglishModel
) when creating the
AgentSession
in your
entry
function and pass it as the
turn_detection
parameter alongside `stt`/`llm`/`tts`. To help further, could you share: • Your language (Python or Node.js)? • The code you tried in
prewarm
and any error messages or behavior you saw? Sources: Agent server options | LiveKit docs | Silero VAD plugin | LiveKit docs | Turn detection and interruptions | LiveKit Docs | LiveKit turn detector plugin | LiveKit docs