millions-actor-82937
09/17/2025, 10:36 PMtall-airline-16756
09/17/2025, 10:36 PMtall-airline-16756
09/17/2025, 10:37 PMupdate_instructions() method in the RealtimeModel class to update the system prompt on the fly. Just a heads up, this will restart the session to apply the new instructions. Here's a quick example:
# Assuming you have a realtime_model instance
await realtime_model.update_instructions("You are a financial advisor. Be concise and accurate.")
• Using JavaScript Frontend: If you're working with a web app, the add_system_anytime() function is a great way to update the system prompt without restarting the session. Here's how you might do it:
const chat = new SimpleChat("my-chat");
chat.add_system_anytime("You are a friendly assistant. Be helpful and kind.", "user-action");
If you have any questions or want me to walk you through a specific example tailored to your needs, just let me know—I'm here to help!
Sources: livekit-agents/livekit/agents/voice/chat_cli.py | tools/server/public_simplechat/readme.md | Vision Agent Quickstart | LiveKit Docs | Vision Agent Quickstart | LiveKit Docsmillions-actor-82937
09/17/2025, 10:47 PMtall-airline-16756
09/17/2025, 10:48 PMupdate_tools() method from the Agent class. This handy method lets you replace the current tools with a fresh list and keeps everything in sync with your session. Here’s a quick example:
# Add a new tool dynamically
await agent.update_tools(agent.tools + [new_tool])
If you want to remove tools, you can easily filter the current list like this:
# Remove a specific tool
tools = [t for t in agent.tools if t != tool_to_remove]
await agent.update_tools(tools)
Feel free to reach out if you’d like more details or examples tailored to your situation—I’m here to help!
Sources: Tool definition and use | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | tool_calling/update_tools.pymillions-actor-82937
09/17/2025, 11:16 PMupdate_instructions method is for a RealtimeSession object, how do I access that object?tall-airline-16756
09/17/2025, 11:16 PMRealtimeSession object from an AgentSession, you can use the realtime_llm_session property in Python or the realtimeLLMSession property in JavaScript/TypeScript. This property gives you the session linked to the agent's activity context.
Python Example:
# Access the RealtimeSession
try:
realtime_session = agent.realtime_llm_session
# Use the session, for example, to update instructions
await realtime_session.update_instructions("New system prompt")
except RuntimeError as e:
print("Realtime session is not available:", e)
JavaScript Example:
// Access the RealtimeSession
const realtimeSession = agentActivity.realtimeLLMSession;
if (realtimeSession) {
realtimeSession.updateInstructions("New system prompt");
} else {
console.error("Realtime session is not available.");
}
Just a quick reminder to make sure your agent is running and that a RealtimeModel is provided to the Agent or AgentSession. The RealtimeSession only gets created in this setup. If anything feels unclear or you want to dive deeper, please don’t hesitate to ask—I’m here to help!
Sources: livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/__init__.... | plugins/google/src/beta/realtime/realtime_api.ts