acceptable-dream-85180
08/19/2025, 7:48 PMtall-airline-16756
08/19/2025, 7:49 PMtall-airline-16756
08/19/2025, 7:49 PMuseVoiceAssistant
hook is your friend for tracking the agent's state. Here's a quick example:
import { useVoiceAssistant } from '@livekit/components-react';
function MyComponent() {
const { state: agentState } = useVoiceAssistant();
const isAgentSpeaking = agentState === 'speaking';
}
• Participant Attributes: You can also watch the lk.agent.state
attribute for any changes. Check this out:
room.on('participant_attributes_changed', (changedAttributes, participant) => {
if (participant.kind === ParticipantKind.AGENT) {
const agentState = participant.attributes['lk.agent.state'];
if (agentState === 'speaking') {
console.log('Agent started speaking');
}
}
});
The agent's state can be one of these: 'initializing'
, 'listening'
, 'thinking'
, or 'speaking'
. If you want me to walk you through anything else or have questions, just give me a shout!
Sources: avatars/hedra/education_avatar/education-frontend/components/session-view.t... | agents/src/multimodal/multimodal_agent.ts | Turn detection and interruptions | LiveKit Docs | agent/main.py | Web and mobile frontends | LiveKit Docs