little-king-41579
05/03/2026, 1:28 PMtall-airline-16756
05/03/2026, 1:28 PMtall-airline-16756
05/03/2026, 1:28 PMChatContext. Create a copy, filter out the messages you want to skip, then update or use that copy for the next action.
• Use the copy() helpers to exclude common categories:
◦ exclude_instructions / excludeInstructions — omit system/developer prompts
◦ exclude_function_call / excludeFunctionCall — omit tool/function calls
◦ exclude_handoff / excludeHandoff — omit handoff markers
◦ exclude_empty_message / excludeEmptyMessage — omit empty messages
◦ exclude_config_update (Python) — omit agent config updates
Examples:
1. Python (exclude instructions & function calls)
next_ctx = self.chat_ctx.copy(exclude_instructions=True, exclude_function_call=True)
1. Node.js (same)
const nextAgentCtx = this.chatCtx.copy({ excludeInstructions: true, excludeFunctionCall: true });
• To remove specific user or agent turns beyond those categories, call copy(), then programmatically filter the returned messages (e.g., drop items where role === 'user' or role === 'assistant'), and either:
◦ pass that filtered chat_ctx into generate_reply() for a single reply, or
◦ call update_chat_ctx() with the modified snapshot to apply changes.
If you tell me whether you’re using Python or Node.js and whether you want this only for a single reply or to permanently update the stored context, I’ll give the exact code snippet for your case.
Sources: How to Build a Background Observer for Voice AI Guardrails | LiveKit | Chat context | LiveKit Documentation | Agent speech and audio | LiveKit Documentation | Agents and handoffs | LiveKit Documentation, with interactive elements