silly-baker-11446
08/28/2025, 7:45 PMtall-airline-16756
08/28/2025, 7:45 PMtall-airline-16756
08/28/2025, 7:45 PMon_user_turn_completed node—it gets a turn_ctx parameter that holds the entire ChatContext up until, but not including, the user's latest message. So, it includes all the back-and-forth from previous turns, both what the user said and the LLM's replies.
Now, the user's newest message comes in separately as the new_message parameter. Once the hook runs, this new_message gets added to the chat context so the LLM can work its magic. Just so you know, neither turn_ctx nor new_message includes the LLM’s response to the current user turn yet—that’s still on its way.
Sources: Pipeline nodes and hooks | LiveKit Docssilly-baker-11446
08/28/2025, 7:59 PMtall-airline-16756
08/28/2025, 8:00 PMsilly-baker-11446
08/28/2025, 8:00 PMtall-airline-16756
08/28/2025, 8:01 PMmetadata field in the RoomAgentDispatch configuration while generating the participant access token. This lets you include custom data, like your project ID, in a neat, structured format such as JSON.
Here’s how you can do it step-by-step:
1. Set Up the Token Server: On your token generation server, you’ll want to configure the roomConfig property of the AccessToken to include an agent dispatch with your custom metadata. For example, in TypeScript:
import { AccessToken } from 'livekit-server-sdk';
import { RoomConfiguration, RoomAgentDispatch } from '@livekit/protocol';
const createTokenWithCustomData = (): Promise<string> => {
const at = new AccessToken();
at.identity = 'my-participant';
at.addGrant({ roomJoin: true, room: 'my-room' });
// Here’s where you pass your custom data via metadata
at.roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: 'test-agent',
metadata: JSON.stringify({
project_id: 'your-project-id',
user_id: '12345',
custom_field: 'custom-value',
}),
}),
],
});
return at.toJwt();
};
2. Access Data in the Agent: Then, in your agent’s entrypoint function, you can grab the metadata through the JobContext. Here’s a quick example in Python:
from livekit.agents import JobContext
async def entrypoint(ctx: JobContext):
# Let’s parse the job metadata
metadata = json.loads(ctx.metadata) if ctx.metadata else {}
project_id = metadata.get("project_id")
print(f"Project ID: {project_id}")
This way, your project ID gets passed along dynamically to the agent, making it super easy to customize its behavior based on that info. If you have any questions or want to chat more about it, just let me know!
Sources: Web Embed Example | livekit/livekit_composite | DeepWiki | Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docs | examples/agent-dispatch/index.ts | src/pages/api/token.tssilly-baker-11446
08/28/2025, 8:15 PMtall-airline-16756
08/28/2025, 8:16 PMInterviewPlanningTask right at the start and keep using it throughout the session. This fits well with how LiveKit is designed and helps keep things consistent and easy to manage.
By sticking with the same task, you make sure it keeps track of the context and makes updates simpler, while still being able to handle the latest chat info from turn_ctx each time. If you made a new task every turn, you'd end up repeating yourself and it would get harder to maintain—definitely not the best for smooth, repeatable interactions.
Feel free to reach out if you'd like me to explain anything more or help you set this up!
Sources: Workflows | LiveKit Docssilly-baker-11446
08/28/2025, 8:52 PMtall-airline-16756
08/28/2025, 8:52 PMAgentTask in LiveKit is:
from livekit.agents import AgentTask
If you have any questions or need a hand with anything else, feel free to ask. I'm here to help!
Sources: livekit-agents/livekit/agents/py.typed | Workflows | LiveKit Docssilly-baker-11446
08/28/2025, 8:54 PMtall-airline-16756
08/28/2025, 8:55 PMChatContext. Thanks!silly-baker-11446
08/28/2025, 8:55 PMtall-airline-16756
08/28/2025, 8:55 PMChatContext in LiveKit is by using chat_ctx.add_message. This method is made just for this purpose, letting you add messages with details like role, content, and even some optional metadata, so everything stays organized and works smoothly.
It’s usually not a great idea to mess with messages directly (like using chat_ctx.messages.append) because the ChatContext class doesn’t actually give direct access to a messages attribute in Python. If you want, I’m happy to share more examples or explain further—just let me know!
Sources: tests/test_llm.py | Large language model (LLM) integrations | LiveKit Docs | agents/src/llm/chat_context.tssilly-baker-11446
08/29/2025, 5:09 PMtall-airline-16756
08/29/2025, 5:10 PMnew_message inside the on_user_turn_completed method, you’ll want to use the text_content property—not as a method. Like this:
text = new_message.text_content
Just a couple of things to keep in mind:
• text_content is a property, so no parentheses! Calling new_message.text_content() will cause an error.
• This property pulls together all the text bits from new_message.content, skipping anything that’s not text, like images.
If you want me to walk you through it more or need some examples, just let me know—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | complex-agents/vision/agent.py | Pipeline nodes and hooks | LiveKit Docssilly-baker-11446
08/29/2025, 5:53 PMtall-airline-16756
08/29/2025, 5:54 PMroomConfig.agents in the token, here are a few things to double-check:
1. Set agent_name in WorkerOptions: Your agent needs to be registered with a clear agent_name in its WorkerOptions. This name should exactly match the agentName you’ve put in the token's roomConfig.agents.
2. Configure roomConfig.agents in the Access Token: Make sure your token has a RoomConfiguration object that includes an agents array. Each item should have:
◦ `agentName`: The name of the agent you want to dispatch.
◦ metadata (optional): Any extra context you want to send to the agent.
1. Grant Room Join Permissions: Don’t forget to include a video grant in the token with roomJoin: true and specify the room they’re joining.
Once you’ve got all that set up, LiveKit should take care of dispatching the agent automatically when someone joins the room. If you hit any snags or want to chat more about this, just let me know—I’m here to help!
Sources: examples/agent-dispatch/index.ts | Authentication | LiveKit Docs | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docssilly-baker-11446
08/29/2025, 6:05 PMtall-airline-16756
08/29/2025, 6:06 PMrealtime_audio_output_node. This is where you get to customize the audio output before it reaches the user. Just a heads up, other nodes like stt_node, llm_node, and tts_node aren’t available for the realtime model—they’re part of the STT-LLM-TTS pipeline instead.
On top of that, you’ve got some handy parameters to shape how the model behaves, such as:
• Voice: Choose the voice for audio responses (think "alloy" or "shimmer").
• Temperature: This controls how random or creative the model’s output feels.
• Turn Detection: Helps the model figure out when you’ve finished speaking.
• Modalities: Decide if the model uses text, audio, or both for input and output.
• Instructions: Set the system prompt or guide how the model behaves.
You can set these up when you initialize the model or change them on the fly using the update_options method. If you want me to walk you through any of this or share some examples, just let me know—I’m here to help!
Sources: Pipeline nodes and hooks | LiveKit Docs | OpenAI Realtime API integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.pysilly-baker-11446
08/29/2025, 6:09 PMtall-airline-16756
08/29/2025, 6:10 PMgpt-4o-mini) alongside VAD and turn detection from the Multilingual model. Plus, you can still take advantage of tasks and tweak the llm_node. This setup is fully supported and actually pretty common for building responsive, context-aware voice agents.
Here’s a quick configuration example:
from livekit.agents import AgentSession
from livekit.plugins import openai, deepgram, silero
from livekit.plugins.turn_detector.multilingual import MultilingualModel
session = AgentSession(
stt=deepgram.STT(model="nova-3", language="multi"),
llm=openai.LLM(model="gpt-4o-mini"),
tts=openai.TTS(voice="ash"),
vad=silero.VAD.load(),
turn_detection=MultilingualModel(), # Context-aware turn detection
)
Some key things to keep in mind:
• Tasks: You can easily set up tasks (like function calling) using the @function_tool decorator, and the OpenAI LLM will handle them smoothly.
• Turn Detection: The Multilingual model offers semantic turn detection based on the transcribed text, while Silero VAD takes care of real-time voice activity detection.
• Node Customization: Feel free to modify the llm_node or tts_node to customize how things behave—for example, filtering output before it goes to TTS.
If you want, I’m here to help with more details or guide you through the implementation!
Sources: LiveKit turn detector plugin | LiveKit Docs | examples/voice_agents/basic_agent.py | Gemini Live API integration guide | LiveKit Docs | Building voice agents | LiveKit Docs | complex-agents/turn-taking/README.mdsilly-baker-11446
08/29/2025, 6:13 PMtall-airline-16756
08/29/2025, 6:14 PMMultilingualModel() is a great choice and supports smooth, natural turn detection for conversations.
• STT: Setting up Deepgram STT with model="nova-3" and language="multi" works well for handling multiple languages in transcription.
• LLM: The OpenAI LLM with model="gpt-4o" is fully compatible and integrates nicely with tasks and llm_node overrides.
• TTS: OpenAI TTS using voice="alloy" is a solid pick for generating clear audio responses.
• VAD: Using ctx.proc.userdata["vad"] (probably preloaded with silero.VAD.load()) fits perfectly with LiveKit’s recommendations.
• Endpointing Delays: Setting min_endpointing_delay=0.5 and max_endpointing_delay=6.0 helps keep turn-taking feeling natural and responsive.
Just a couple more things to keep in mind:
• Make sure you’ve downloaded the necessary model weights for MultilingualModel by running python agent.py download-files.
• Double-check that your environment variables like DEEPGRAM_API_KEY and OPENAI_API_KEY are set up correctly.
• For production use, it’s best to run on compute-optimized instances to avoid any CPU slowdowns.
If you have any more questions or need a hand with anything else, just let me know—I’m here to help!
Sources: LiveKit turn detector plugin | LiveKit Docs | complex-agents/drive-thru/agent_config.py | examples/frontdesk/frontdesk_agent.py | agent.py | Voice AI quickstart | LiveKit Docssilly-baker-11446
08/29/2025, 6:17 PMtall-airline-16756
08/29/2025, 6:18 PMsilly-baker-11446
08/29/2025, 6:18 PMtall-airline-16756
08/29/2025, 6:19 PMsilly-baker-11446
08/29/2025, 6:21 PMsilly-baker-11446
08/30/2025, 2:19 AMsilly-baker-11446
08/30/2025, 2:52 AM