I’m using `livekit.agents` to run a 20-min voice i...
# ask-ai
e
I’m using
livekit.agents
to run a 20-min voice interview with STT → LLM → TTS. I override
llm_node
but otherwise rely on the default behavior. I want to confirm my understanding of context handling and billing implications: 1. Does `AgentSession`/`ChatContext` resend the entire accumulated chat history on every LLM turn by default? i.e., user speaks → agent replies → next user turn sends (previous user + previous agent + current user) plus any system/tool messages again. 2. Is there any built-in sliding window or automatic summarization in the Agents SDK, or do we need to manually prune/summarize
chat_ctx.messages
before calling the LLM? 3. Any server-side caching that reduces tokens billed for repeated prefixes across turns? (I assume not—each call is stateless from the LLM provider’s perspective—but checking if the Agents framework or Realtime path does anything here.)
t
Thanks for reaching out, Hamza. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for your questions about context handling and billing implications in the LiveKit Agents SDK! I’m happy to walk you through the details: 1. Resending chat history: By default, `AgentSession`/`ChatContext` sends the entire accumulated chat history with every LLM turn. This means all previous messages from both the user and agent, plus any system or tool messages, are included unless you choose to change this behavior. 2. Sliding window or summarization: The SDK offers a handy sliding window feature through the
truncate()
method, which helps limit how many messages get sent to the LLM. However, automatic summarization isn’t built in—you’d need to add that yourself if it’s something you want. 3. Server-side caching: To help reduce billing for repeated content, the SDK and Realtime path use server-side caching. This clever prompt caching reuses tokens from earlier turns that overlap with new prompts, so you’re not billed repeatedly for the same prefixes. Please feel free to reach out if you’d like me to clarify anything further or if there’s anything else I can help you with! Sources: tools/server/public_simplechat/readme.md | Workflows | LiveKit Docs | agents/src/llm/chat_context.ts | complex-agents/personal_shopper/personal_shopper.py | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti...