how to check if the agent is in speaking state wit...
# ask-ai
b
how to check if the agent is in speaking state without using events
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you check if an agent is in the speaking state without relying on events. You can do this by directly accessing the agent's current state through SDK properties or participant attributes. Here are some friendly examples to guide you: • Swift SDK: Simply use the
agent.agentState
property and see if it equals
.speaking
. • React/JavaScript SDK: You can use the
useAgent
hook and check if
agent.state === 'speaking'
. • Python SDK: Just access
session.agent_state
and compare it to
'speaking'
. • Participant Attributes: Take a look at the agent participant's attribute
lk.agent.state
to see if it holds the value
'speaking'
. If you'd like, I’m here to provide more details or specific examples for any SDK you’re working with—just let me know! Sources: packages/react/src/hooks/useAgent.ts | tests/test_agent_session.py | Events and error handling | LiveKit docs | Web and mobile frontends | LiveKit docs | Sources/LiveKit/Agent/Agent.swift