aloof-scooter-47164
09/06/2025, 12:26 AMtall-airline-16756
09/06/2025, 12:26 AMtall-airline-16756
09/06/2025, 12:27 AMLISTENING state once it’s successfully connected and initialized. This happens behind the scenes through the AgentSession, which keeps the lk.agent.state attribute updated with the current status. If you ever want to nudge the agent into the LISTENING state after subscription, the best way is to use RPC-based session control methods like these:
• session.interrupt() – This stops any ongoing agent speech and brings it back to listening mode.
• session.commit_user_turn() – This finalizes the user input and kicks off the agent’s response, after which it goes back to listening.
• session.clear_user_turn() – This clears any pending input, which is handy if you want to restart the interaction flow.
Just a heads up: you can’t directly change the lk.agent.state attribute from the client side since it’s read-only and managed internally by the agent session. If you want to make sure the agent is ready and listening, you can keep an eye on the lk.agent.state attribute or listen for the agent_state_changed event to know when it’s in the LISTENING state.
If you’d like me to walk you through any of this or if you have more questions, just let me know—I’m here to help!
Sources: packages/react/src/hooks/useVoiceAssistant.ts | livekit-compose-components/src/main/java/io/livekit/android/compose/state/R... | Turn detection and interruptions | LiveKit Docs | Web and mobile frontends | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.py