wooden-librarian-60399
09/30/2025, 2:28 AMtall-airline-16756
09/30/2025, 2:28 AMtall-airline-16756
09/30/2025, 2:29 AMinterrupted flag to true on the relevant ChatMessage object. Doing so helps the LLM on the next call understand that the agent didn’t get to finish their message.
When an interruption happens, the system captures the part of the text that was spoken before it was cut off and stores it in the chat context with the interrupted flag. This approach works consistently across both Python and Node.js implementations of the LiveKit Agents framework, so you can rely on it no matter which you’re using.
Here’s a quick example in Python:
msg = llm.ChatMessage(
role="assistant",
content=[forwarded_text],
id=msg_gen.message_id,
interrupted=True
)
self._agent._chat_ctx.items.append(msg)
And in Node.js, it looks like this:
const message = ChatMessage.create({
role: 'assistant',
content: forwardedText,
id: msgId,
interrupted: true
});
this.agent._chatCtx.insert(message);
This way, the system keeps everything clear and continuous for downstream LLMs by preserving exactly what the agent said before the interruption. If you have any more questions or want to dive deeper, I’m here to help!
Sources: agents/src/llm/__snapshots__/chat_context.test.ts.snap | examples/voice_agents/session_close_callback.py | Working with the MultimodalAgent class | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | Turn detection and interruptions | LiveKit Docswooden-librarian-60399
09/30/2025, 2:32 AMtall-airline-16756
09/30/2025, 2:32 AMwooden-librarian-60399
09/30/2025, 2:33 AMtall-airline-16756
09/30/2025, 2:34 AM