silly-baker-11446
09/02/2025, 9:04 PMtall-airline-16756
09/02/2025, 9:04 PMtall-airline-16756
09/02/2025, 9:05 PMsession.history property. This holds the entire conversation as a ChatContext object, and it updates automatically as your chat goes on.
Here’s a quick rundown on how to use it:
• Accessing History: Just grab session.history whenever you want to see the full conversation so far during the session.
• Preserving Context: To keep the context flowing across turns or when switching agents, simply pass the current chat_ctx to the new agent or task, like this: return TechnicalSupportAgent(chat_ctx=self.session.chat_ctx).
• Real-Time Updates: You can listen for events like conversation_item_added to get notified whenever something new pops up in the chat history.
• Saving and Loading: After the session wraps up, save session.history to a file (like JSON), and later reload it by rebuilding the ChatContext and passing it back to the agent when you start again.
If you want me to walk you through any part or share some examples, just give me a shout!
Sources: Session recording and transcripts | LiveKit Docs | Workflows | LiveKit Docs | Testing and evaluation | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.py | OpenAI Realtime API integration guide | LiveKit Docs