how do I transfer chat context from one agent to a...
# ask-ai
f
how do I transfer chat context from one agent to another?
t
Thanks for reaching out, Taras. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m happy to help you with transferring chat context from one agent to another in LiveKit! Using agent handoff with context preservation is a great way to make sure the new agent has all the important conversation history, so your users won’t have to repeat themselves. Here’s a simple way to do it: • Pass the previous agent’s chat context along to the new agent. • Copy the chat history, and if needed, you can truncate it to keep things running smoothly and relevant. • Merge this context into the new agent’s
chat_ctx
before you activate them. • Then, use
agent.update_chat_ctx()
to apply these changes. If you’d like, I’m here to provide more details or examples—just let me know, and I’ll gladly guide you through it! Sources: complex-agents/role-playing/agents/base_agent.py | Docs::Agents | Docs::Telephony | Workflows | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py