some-breakfast-27057
09/20/2025, 2:20 PMnew_chat_ctx = self.session.chat_ctx.truncate(max_items=20)tall-airline-16756
09/20/2025, 2:20 PMtall-airline-16756
09/20/2025, 2:21 PMChatContext.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