wooden-librarian-60399
09/04/2025, 2:37 AMtall-airline-16756
09/04/2025, 2:37 AMtall-airline-16756
09/04/2025, 2:38 AMinterrupted=True flag. This way, incomplete responses aren’t mistaken for finished ones.
• For real-time models, interruptions are handled right on the server side by cutting off the message at the playback point and marking it as interrupted in the context.
• You can also stop speech programmatically using the interrupt() method, which makes sure the context is updated before moving forward.
These features help the LLM stay aware of any incomplete messages and respond just right. If you want, I’m happy to share more details or examples!
Sources: livekit-agents/livekit/agents/voice/speech_handle.pywooden-librarian-60399
09/04/2025, 2:43 AMtall-airline-16756
09/04/2025, 2:43 AMplayback_position property to figure out when an interruption happened—like how many seconds into the response it occurred. This way, it can trim the conversation history to include only the part that was actually spoken before the interruption.
That said, non-realtime models don’t sync context down to the millisecond or roll back exactly to the interruption point like realtime models do. The timing info helps keep things accurate, but it’s not quite as precise as what you’d get with realtime syncing.
If you want me to walk you through it more or give some examples, just let me know—I’m happy to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Turn detection and interruptions | LiveKit Docswooden-librarian-60399
09/04/2025, 2:47 AMtall-airline-16756
09/04/2025, 2:47 AMplayback_position property in events like playback_finished shows how many seconds of the agent's audio played before it got interrupted.
• Interruption Metrics: Things like clientAudioSubscriberInterruptionCount (how many interruptions happened) and clientAudioSubscriberTotalInterruptionDuration (how long those interruptions lasted) give you extra details.
• Event Timestamps: Events such as agent_state_changed and playback_finished come with created_at timestamps, which help you figure out exactly when interruptions happened compared to the session start.
These details should help you understand when and how interruptions occur. If you want me to walk you through it more or share some examples, just let me know—I’m happy to help!
Sources: Sources/LiveKit/Protos/livekit_metrics.pb.swift | protobufs/livekit_metrics.proto | livekit-agents/livekit/agents/voice/agent_activity.py | Turn detection and interruptions | LiveKit Docswooden-librarian-60399
10/01/2025, 1:09 AMtall-airline-16756
10/01/2025, 1:09 AMuse_tts_aligned_transcript setting! This feature helps align the transcription perfectly with the actual speech timing from the TTS engine. It makes sure that what you see in the transcription matches the audio playback, supporting word-level alignment for providers like Cartesia and ElevenLabs, and sentence-level alignment for others. This really helps improve the accuracy of the transcriptions when displayed.
Now, regarding interruptions, this setting doesn’t directly notify the LLM about them. Instead, LiveKit takes care of interruptions by cutting off the ongoing message and marking it as interrupted in the chat context. This way, the LLM knows an interruption happened and can adjust its responses accordingly.
If you'd like, I’m here to provide more details or examples—just let me know!
Sources: Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | Cartesia TTS integration guide | LiveKit Docs | ElevenLabs TTS integration guide | LiveKit Docswooden-librarian-60399
10/01/2025, 1:14 AMtall-airline-16756
10/01/2025, 1:15 AMsynchronizedTranscript from the playback event, which holds the text right up to where the interruption took place.
Then, this shortened transcript is added to the chat context with an interrupted=true flag. This helps the LLM recognize both that an interruption occurred and the precise moment it happened, so it can tailor its responses more effectively.
If you have any questions or want me to walk you through this in more detail, please don’t hesitate to ask—I’m here to help!
Sources: agents/src/voice/agent_activity.ts | livekit-agents/livekit/agents/voice/agent_activity.pywooden-librarian-60399
10/01/2025, 1:20 AMtall-airline-16756
10/01/2025, 1:21 AMcontent array with multiple Content objects, which allows for rich multimodal inputs and outputs.
◦ `InputTextContent`: Text input from the user.
◦ `InputAudioContent`: Audio input from the user.
◦ `TextContent`: Text output from the assistant.
◦ `AudioContent`: Audio output from the assistant, including a transcript.
• Part Object: This is used in a couple of ways:
◦ ContentPart: Helps manage real-time updates as a message is being generated, showing text or audio parts as they come in.
◦ types.Part: Represents segments of the LLM’s output, including text or function calls, helping to organize and process the responses.
These objects really help keep the interactions dynamic and real-time in LiveKit. If you’d like, I’m here to walk you through more details or provide examples—just let me know!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py | agents/src/llm/__snapshots__/chat_context.test.ts.snapwooden-librarian-60399
10/01/2025, 2:03 AMtall-airline-16756
10/01/2025, 2:04 AMChatMessage containing the full content is added to the chat context.
4. Interruption Detection: If you interrupt—whether by speaking or typing—or if a programmatic trigger occurs, the system immediately cancels tasks like TTS and LLM generation to respect your input.
5. Partial Message Handling: If the assistant is interrupted mid-response, it captures the part that was spoken using the synchronizedTranscript from playback events. This partial message is then added to the chat context with interrupted=true, so nothing gets lost.
6. Truncation for Realtime Models: For realtime models, the server-side message is trimmed to match the actual playback position, keeping everything consistent.
7. State Update: After an interruption, the agent smoothly switches from "speaking" to "listening," ready to hear your next input.
This approach helps make sure the chat context truly reflects what you experienced, even if interruptions happen. If you’d like me to clarify anything or provide examples, just let me know—I’m here to help!
Sources: Bringing AI avatars to voice agents | VoicePipelineAgent | LiveKit Docs | tests/test_agent_session.py | agents/src/voice/agent_activity.ts