```proc.userdata["vad"] = silero.VAD.load()``` ```...
# agents
f
Copy code
proc.userdata["vad"] = silero.VAD.load()
Copy code
turn_detection=MultilingualModel(),
        vad=ctx.proc.userdata["vad"],
        preemptive_generation=True,
Above is my agent configuration.
Copy code
@session.on("user_state_changed")
    def _on_user_state_changed(ev):
        """Track user state changes (speaking vs listening)"""
        logger.info(f"user_state_changed + {ev.old_state} -> {ev.new_state}")
callbacks are not coming when use is having the conversation. what could be the possible reason?
@refined-appointment-81829 if you can check
l
I can't see a preexisting example so I added the
user_state_changed
to one of our basic examples as follows and I see the callbacks, can you see if this works for you?
Copy code
import logging
import os
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, UserStateChangedEvent, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import silero
from livekit.plugins.turn_detector.multilingual import MultilingualModel

load_dotenv(dotenv_path=Path(__file__).parent.parent / '.env')

logger = logging.getLogger("listen-and-respond")
logger.setLevel(logging.INFO)

class ListenAndRespondAgent(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions="""
                You are a helpful agent. When the user speaks, you listen and respond.
            """,
            stt="assemblyai/universal-streaming",
            llm="openai/gpt-4.1-mini",
            tts="cartesia/sonic-2:6f84f4b8-58a2-430c-8c79-688dad597532",
            vad=silero.VAD.load()
        )

    async def on_enter(self):
        self.session.generate_reply()

async def entrypoint(ctx: JobContext):
    session = AgentSession(
        turn_detection=MultilingualModel()
    )

    @session.on("user_state_changed")
    def on_user_state_changed(event: UserStateChangedEvent):
        logger.info(f"User state changed: {event.old_state} -> {event.new_state}")

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

if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
f
I was checking some other thread and it looks like this is something related to turn_detection. can you check if this works when
turn_detection=MultilingualModel(),
is added to the Agent?