creamy-window-79763
02/27/2026, 10:42 AMtall-airline-16756
02/27/2026, 10:42 AMtall-airline-16756
02/27/2026, 10:43 AMFunctionCall events with a one-line summary (who/what/intent/time).
◦ Strip out old FunctionCallOutput payloads entirely, or store them externally and reference them by ID.
◦ Always keep the current question’s FunctionCall/Output pair intact.
• Use a ConversationManager helper pattern (or similar middleware) to manage what gets sent to the LLM:
◦ Maintain the full history in session.history (or your own store).
◦ When preparing chat_ctx for the LLM, build a reduced context that includes:
▪︎ Recent messages (last N turns).
▪︎ System message summarizing earlier turns (one-line or short bullet list).
▪︎ Summaries for old FunctionCalls in place of full events.
◦ Optionally include pointers/IDs to the stripped outputs in case you need to rehydrate them later.
Practical tips to implement
1. Decide retention rules:
◦ e.g., keep last 3 Q/A turns fully, summarize anything older than that.
1. Create concise summary format:
◦ For FunctionCall: "Q5: validated_user_email -> validated (params: {email_masked})"
◦ For FunctionOutput removed: "Output for Q3 stored at output_id:12345"
1. Store full outputs in external storage (DB or object store) and reference by ID to avoid token costs.
2. Run periodic summarization:
◦ After every X questions, append a short summary system message (1–2 lines) representing the combined earlier context.
1. Measure and iterate:
◦ Track tokens, TTFT, and LLM cost to tune retention/summarization thresholds.
If helpful, I can:
• Sketch a small pseudocode flow for a ConversationManager that filters/summarizes history before calling the LLM.
• Suggest concrete summary templates for your FunctionCall and FunctionCallOutput items.
• Recommend thresholds (how many turns to keep vs summarize) based on your 37-question workflow.
Which would you prefer next: a pseudocode flow you can drop into your agent, or a few concrete summary templates to use right away?
Sources: Building multi-agent architectures with LiveKit agents | LiveKit