can we force and set the user state to away?
# ask-ai
a
can we force and set the user state to away?
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! I wanted to share that in LiveKit, the user state switches to "away" automatically after a certain period of inactivity, controlled by the
user_away_timeout
setting. Unfortunately, this state can’t be set manually or overridden through code. However, if you’re looking to indicate when a user is away or manage their status more flexibly, a great option is to use custom participant metadata or keep track of user states within your own application. I’d be happy to walk you through how to set this up if you’re interested—just let me know! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Events and error handling | LiveKit Docs | State synchronization
a
and to update the system instructions mid session of the Realtime model?
t
I'm happy to help you with updating system instructions mid-session in the Realtime model! Here’s how you can do it using your SDK: • Python SDK: Simply use
await agent.update_instructions("New system instructions here")
to update your instructions on the fly. • JavaScript SDK: You can call
await session.updateInstructions("New system instructions here")
to send the updated instructions through the
session.update
event. Just a quick note about how this works depending on your provider: • OpenAI: You’re in luck! It supports smooth mid-session updates without needing to restart. • Google (Gemini): You might need to restart the session to see the changes take effect. • Ultravox: It’s important to mark the session for restart when you update instructions. If you have any questions or want me to walk you through the implementation, please don’t hesitate to ask. I’m here to help! Sources: agents/src/llm/realtime.ts | livekit-agents/livekit/agents/llm/realtime.py
a
and to clear the session chat context?
t
To help you clear the session chat context in the LiveKit Realtime model, you can simply use the
update_chat_ctx
method with an empty
ChatContext
. This will gently reset the conversation history for your session, giving you a fresh start. Here’s a friendly example in Python to guide you:
Copy code
from livekit.agents.llm import ChatContext

# Assuming you have a reference to your RealtimeSession
await realtime_session.update_chat_ctx(ChatContext.empty())
This method works smoothly across various providers like OpenAI, Google, AWS, and Ultravox. If you’d like, I’m here to help you with any part of the implementation or answer any questions you have! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | plugins/google/src/beta/realtime/realtime_api.ts