salmon-airplane-11201
09/30/2025, 11:43 AMtall-airline-16756
09/30/2025, 11:43 AMtall-airline-16756
09/30/2025, 11:44 AMChatContext parameter to load previous messages and pass them to an agent when starting a session. Here’s a simple example to help you get started:
from livekit.agents import ChatContext
chat_ctx = ChatContext.empty()
chat_ctx.add_message(role="assistant", content="Hello, how can I help you?")
chat_ctx.add_message(role="user", content="I want to plan a trip to Paris.")
By passing this chat_ctx to the agent, you’ll be able to maintain the conversation context smoothly. Also, keep in mind that the full conversation history is accessible through session.history. If you want to save chat history beyond a session, you can easily set up external storage for that. I hope this helps you keep your chats seamless and connected!
Sources: Workflows | LiveKit Docs | examples/voice_agents/realtime_load_chat_history.py | Docs::Agents | Session recording and transcripts | LiveKit Docs | OpenAI Realtime API integration guide | LiveKit Docs