do you have more doc about 1. 2. *Selective Cont...
# ask-ai
s
do you have more doc about 1. 2. Selective Context Transfer: If you want more control, you can truncate or filter the chat context before passing it along to the new agent.
new_chat_ctx = self.session.chat_ctx.truncate(max_items=20)
t
Thanks for reaching out, MBMBMB. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Selective context transfer is a helpful way to trim or filter the chat context before passing it along to a new agent. You can do this using methods like
ChatContext.copy()
and
truncate()
, combined with some custom filtering logic. Let me share a few examples to give you a clearer picture: • Medical Office Triage: This filters messages by type and keeps only the last
n
messages to maintain the most relevant context. • Personal Shopper Assistant: Here, the chat context is copied and truncated while making sure customer details and order status are preserved. • Role-Playing Game Agent: In this case, a larger chat history is kept to maintain the flow of the story. • Supervisor Escalation: This approach summarizes conversations by removing empty messages, function calls, and system instructions for clarity. Also, dynamic truncation can be applied just before LLM inference to make the best use of tokens. If you'd like, I’m happy to walk you through detailed implementation steps or answer any questions you might have! Sources: complex-agents/personal_shopper/README.md | Agent-assisted warm transfer | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | examples/voice_agents/restaurant_agent.py