fast-egg-39595
08/26/2025, 3:29 PMtall-airline-16756
08/26/2025, 3:29 PMtall-airline-16756
08/26/2025, 3:30 PMvoice_id while you're in the middle of a session with LiveKit Agent 1.x, you can easily do that using the update_options() method on your TTS instance. This lets you switch up the voice_id and tweak other settings on the fly.
Here’s a quick example:
# Assuming you have a reference to your agent or its session
agent.tts.update_options(voice_id="new_voice_id_here")
This way, you can update the voice without having to create a whole new TTS instance. If you have any questions or want me to walk you through it, just let me know!
Sources: ElevenLabs TTS integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-elevenlabs/README.md | pipeline-tts/tts_comparison.pyfast-egg-39595
08/26/2025, 3:59 PMtall-airline-16756
08/26/2025, 4:00 PMupdate_instructions method on your agent instance. This lets you tweak the instructions on the fly without any hassle.
Here’s a quick example for you:
await agent.update_instructions("You are now speaking on a phone call.")
The best part? The changes kick in right away—no need to restart the session. If you have any questions or want me to walk you through it, just let me know!
Sources: agent/main.py | basics/change_agent_instructions.py | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real...fast-egg-39595
08/26/2025, 4:02 PMtall-airline-16756
08/26/2025, 4:02 PMfast-egg-39595
08/26/2025, 4:04 PMtall-airline-16756
08/26/2025, 4:04 PMgemini-2.5-flash instead of a realtime model doesn’t automatically stop you from updating system instructions mid-session. That said, there are a few things to keep in mind:
• The update_instructions method is available in LiveKit Agent 1.x and lets you tweak instructions on the fly.
• With gemini-2.5-flash, making updates might cause the session to restart, which could interrupt the flow of your conversation.
• Also, the Gemini Live API preview has some known quirks that might affect how smoothly instruction updates work.
If you decide to go ahead with update_instructions, just be mindful of these possible hiccups. And hey, if you want me to explain anything further or need a hand, I’m here to help!
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/models.py | Gemini Live API integration guide | LiveKit Docsfast-egg-39595
08/26/2025, 4:23 PMtall-airline-16756
08/26/2025, 4:24 PMupdate_instructions method. It takes care of restarting the session behind the scenes whenever needed, so your new instructions get applied smoothly.
Here’s a quick example:
await agent.update_instructions("You are a helpful assistant speaking on the phone.")
The framework will handle the session restarts automatically to make sure everything updates correctly. If you have any questions or want me to walk you through it, just let me know—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_session.py | basics/change_agent_instructions.pyfast-egg-39595
08/26/2025, 4:26 PMtall-airline-16756
08/26/2025, 4:26 PMsession.history.
If you want to keep the conversation flowing smoothly across restarts, here are a couple of easy ways to do that:
• When you create your Agent or AgentTask, you can pass along the previous session’s chat_ctx using the chat_ctx parameter.
• Or, you can use the update_chat_ctx method to add the initial chat history right when your session starts up.
If you’d like, I’m here to help you set this up—just let me know!
Sources: Workflows | LiveKit Docs | Workflows | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...fast-egg-39595
08/26/2025, 6:23 PMtall-airline-16756
08/26/2025, 6:24 PMSpeechmaticsUserData) to link those speaker IDs (like S1, S2) to the names you want.
• Catch the transcription stream and swap the speaker ID for your mapped name in the transcript.text field before it moves along in the process.
Plus, you can use a handy function like set_speaker_name to create or update these mappings on the fly during a session. If you want, I’m here to help you get this set up!
Sources: pipeline-stt/diarization.pyfast-egg-39595
08/26/2025, 6:26 PMtall-airline-16756
08/26/2025, 6:26 PM# Example mapping of speaker IDs to names
speaker_mapping = {
"S1": "Alice",
"S2": "Bob"
}
# Function to process and replace speaker IDs
def process_transcript(transcript):
speaker_id = transcript.get("speaker_id")
if speaker_id in speaker_mapping:
# Replace speaker ID with the mapped name
transcript["text"] = f"{speaker_mapping[speaker_id]}: {transcript['text']}"
return transcript
# Example usage
transcript_event = {
"speaker_id": "S1",
"text": "Hello, how are you?"
}
# Process the transcript
updated_transcript = process_transcript(transcript_event)
print(updated_transcript)
This will give you:
{
"speaker_id": "S1",
"text": "Alice: Hello, how are you?"
}
Feel free to plug this into your LiveKit transcription stream processing. And if you want a hand with anything else, just give me a shout!fast-egg-39595
08/26/2025, 6:30 PMtall-airline-16756
08/26/2025, 6:30 PMllm_node is a great tool to tweak the chat context before it gets sent to the LLM in LiveKit Agent 1.x. It gives you the flexibility to customize how the LLM is used, like adding or changing context on the fly.
For instance, you can override the llm_node method in your own Agent subclass to preprocess the chat_ctx before it reaches the LLM. People often do this for things like retrieval-augmented generation (RAG) or to dynamically add speaker mappings into the context.
If you'd like, I’d be happy to share a code example or help you get started with this—just let me know!
Sources: Agents v0.x migration guide | LiveKit Docs | Agents 0.x migration guide | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docs | Voice pipeline nodes | LiveKit Docsfast-egg-39595
08/26/2025, 6:31 PMtall-airline-16756
08/26/2025, 6:31 PMllm_node is definitely a great pick. It lets you preprocess the chat context on the fly before sending it to the LLM, which keeps things flexible and plays nicely with LiveKit's setup.
I'd be happy to share an easy example of how to override the llm_node method to add speaker mappings or tweak the context in other ways. Just let me know if you'd like me to walk you through it!fast-egg-39595
08/26/2025, 6:32 PMtall-airline-16756
08/26/2025, 6:32 PMllm_node method to tweak the chat context on the fly before sending it off to the LLM:
from livekit.agent import Agent
class CustomAgent(Agent):
async def llm_node(self, chat_ctx, tools, model_settings):
# Just a quick example: adding speaker mappings into the chat context
speaker_mapping = {
"S1": "Alice",
"S2": "Bob"
}
# Let’s update the chat context dynamically
for message in chat_ctx.messages:
if "speaker_id" in message:
speaker_id = message["speaker_id"]
if speaker_id in speaker_mapping:
message["text"] = f"{speaker_mapping[speaker_id]}: {message['text']}"
# Now, we call the original method with our updated context
return await super().llm_node(chat_ctx, tools, model_settings)
# Here’s how you create and use your custom agent
agent = CustomAgent()
This snippet shows you how to add speaker names into chat_ctx.messages before it goes to the LLM. Feel free to tweak it to fit what you need! And hey, if anything’s unclear or you want to dive deeper, just ask—I’m here to help!