average-leather-27589
12/01/2025, 7:12 AMtall-airline-16756
12/01/2025, 7:12 AMtall-airline-16756
12/01/2025, 7:13 AMfrom livekit.agents import ChatContext
new_context = ChatContext()
await agent.update_chat_ctx(new_context)
• TypeScript
import { llm } from '@livekit/agents';
const newContext = llm.ChatContext.empty();
await agent.updateChatCtx(newContext);
This clears prior messages, tool calls, and context while the agent remains connected and ready for new input. Would you like an example that preserves certain system messages or user metadata when clearing the rest of the conversation?
Sources: Pipeline nodes and hooks | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docsaverage-leather-27589
12/01/2025, 7:21 AMtall-airline-16756
12/01/2025, 7:22 AMAgentSession doesn't create the Agent for you. To get an agent when using your session, instantiate an Agent and pass it into session.start(). After start, the agent is available as session.agent.
Example (Python):
from livekit.agents import Agent, AgentSession
from livekit.plugins import openai
class MyAgent(Agent):
def __init__(self):
super().__init__(instructions="You are a helpful assistant.")
agent = MyAgent()
session = AgentSession(
llm=openai.realtime.RealtimeModel(voice="sage"),
)
# start the session with your agent
await session.start(room=ctx.room, agent=agent)
# access the agent
current_agent = session.agent
print(current_agent.instructions)
Would you like an example that adds custom state or shows how to call agent.update_chat_ctx() to clear conversation context while keeping the connection?
Sources: Agent session | LiveKit docs | Agents and handoffs | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docsaverage-leather-27589
12/01/2025, 7:24 AMtall-airline-16756
12/01/2025, 7:24 AMsession.agent becomes available only after await session.start(...) completes and the session is fully started.
Quick checklist and example to fix this:
1. Ensure you await start before accessing session.agent.
2. Keep a reference to the agent you pass in (simpler and reliable).
3. Optionally listen for the session's agent-state event to know when it's ready.
Example (Python):
agent = LocalAgent() # create agent instance
session = AgentSession(llm=...) # your session
await session.start(agent=agent, room=ctx.room) # wait for start to finish
# now safe to access
current_agent = session.agent
# or use the original reference
current_agent = agent
If you still get the error after awaiting start, tell me:
• the exact SDK version you're using, and
• whether you call session.agent before or after await session.start(...). Sources: Agent session | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docsaverage-leather-27589
12/01/2025, 8:07 AMtall-airline-16756
12/01/2025, 8:07 AMawait session.interrupt()
# or if you have a SpeechHandle:
handle.interrupt()
1. Disable automatic resumption of interrupted speech when creating the session:
session = AgentSession(
llm=...,
resume_false_interruption=False,
)
1. Clear the conversation context after interrupting so no pending messages continue:
from livekit.agents import ChatContext
await agent.update_chat_ctx(ChatContext())
1. (Optional) Stop listening/receiving audio while hidden:
await session.input.set_audio_enabled(False)
Sequence to use when hiding:
1. await session.interrupt()
2. await agent.update_chat_ctx(ChatContext())
3. await session.input.set_audio_enabled(False) (if you want to pause input)
When resuming, re-enable audio and continue; the cleared chat context prevents unfinished messages from replaying.
Do you want a concrete example showing this full hide/resume flow in your current code?
Sources: Agent speech and audio | LiveKit docs | Turn detection and interruptions | LiveKit Docs | Agents v0.x migration guide - Python | LiveKit docs | Text and transcriptions | LiveKit docsaverage-leather-27589
12/01/2025, 9:10 AMtall-airline-16756
12/01/2025, 9:10 AMmax_idle_time and max_session_length are not specified in the LiveKit/Simli integration docs.
• Those two parameters are configurable on your side and control when the session will be considered idle or reach its total allowed duration.
• Continuously keeping an avatar session running to avoid reconnection delays is not the intended pattern — the Simli plugin is designed to start on demand and stop when finished. Running sessions indefinitely may hit service-side timeouts or incur unnecessary resource/cost overhead.
What you can do now:
• Keep your current configuration and experiment with larger values (e.g., increase max_idle_time from 900 and max_session_length from 3600) to see if it meets your latency needs.
• When hiding the session, make sure you properly interrupt and stop the avatar to avoid leftover audio or state (you already use avatar.start(...) / avatar.stop() patterns).
• If you need guaranteed always-on behavior for production low-latency, check Simli’s official docs or ask Simli for service limits and recommended patterns.
Would you like a suggested configuration to test (example values and hide/resume sequence) based on your current numbers?
Sources: Simli virtual avatar integration guide | LiveKit docsaverage-leather-27589
12/05/2025, 2:37 AMtall-airline-16756
12/05/2025, 2:38 AMuse_tts_aligned_transcript=True in your AgentSession to better sync captions with TTS timing.
• Shorten initial responses so the avatar can start rendering sooner.
• Pre-warm/start the avatar session slightly before user-visible output (start the session or request a short silent TTS) to reduce first-frame latency.
• Test outside the Playground UI (the playground can add extra rendering delays).
If you want, I can show how to enable use_tts_aligned_transcript in your session code or suggest TTS provider configs to try. Which would you prefer?
Sources: Simli virtual avatar integration guide | LiveKit docs | Bringing AI avatars to voice agents | Text and transcriptions | LiveKit docsaverage-leather-27589
12/05/2025, 2:38 AMtall-airline-16756
12/05/2025, 2:39 AMuse_tts_aligned_transcript=True) to better sync captions with audio timing.
• Keep responses short or split long responses into smaller chunks.
• Pre‑warm the avatar (start the session or request a tiny silent audio chunk) before showing UI output.
• Test outside the Playground UI to rule out UI rendering delays.
Would you like a short code example to enable aligned transcripts or to pre‑warm the avatar in your current setup?