astonishing-horse-62951
09/26/2025, 4:50 PMtall-airline-16756
09/26/2025, 4:50 PMtall-airline-16756
09/26/2025, 4:51 PMsession.interrupt() method from the LiveKit Agents framework. This handy method lets you stop the agent’s speech right away, no matter if interruptions are turned on or off for the current speech.
Here’s how you can interrupt an agent:
• Using `session.interrupt()`: Just call the interrupt() method on the agent session to immediately pause the agent’s speech. For example:
const handle = session.say("Hello world");
// Later, to interrupt:
session.interrupt();
• Using `SpeechHandle.interrupt()`: If you have a reference to the SpeechHandle (which you get from say() or generate_reply()), you can interrupt that specific speech directly. Like this:
const handle = session.say("Hello world");
handle.interrupt();
When you interrupt, the agent will stop speaking right away and shorten the conversation history to only include what was said before the interruption. If you’d like to dive deeper, feel free to check out the Turns and Interruptions documentation. I hope this helps you get things working smoothly!
Sources: agents/src/voice/agent_activity.ts | Docs::Agents | Turn detection and interruptions | LiveKit Docsastonishing-horse-62951
09/26/2025, 4:54 PMtall-airline-16756
09/26/2025, 4:55 PMsession.interrupt() method on the agent session object. I’m here to help guide you through it!
Here’s a friendly way to implement an Interruption Button in React:
1. Make sure you have access to the Agent Session: Your React component will need the session object, which you can usually pass down through context or state management.
2. Create a Custom Button:
function InterruptButton({ session }) {
const handleClick = () => {
session.interrupt(); // This will interrupt the agent programmatically
};
return (
<button onClick={handleClick} aria-label="Interrupt Agent">
Interrupt
</button>
);
}
Bonus tip: You can use the useVoiceAssistant hook from @livekit/components-react to check the agent’s current state (like if they’re "speaking") and show or enable the button accordingly:
const { state } = useVoiceAssistant();
const isSpeaking = state === 'speaking';
return (
<button onClick={handleClick} disabled={!isSpeaking}>
{isSpeaking ? 'Interrupt' : 'Agent Not Speaking'}
</button>
);
If you’d like, I’m more than happy to walk you through integrating this into your frontend or help you manage the session object in React. Just let me know!
Sources: Docs::Agents | Turn detection and interruptions | LiveKit Docs | Web and mobile frontends | LiveKit Docs | Docs::Agents | complex-agents/drive-thru/frontend/components/livekit/agent-control-bar/age...astonishing-horse-62951
09/26/2025, 5:00 PMtall-airline-16756
09/26/2025, 5:01 PMLiveKitRoom component, which conveniently provides the session (room) context to all child components via React Context. This way, you don’t have to worry about manually passing props down the component tree.
Here’s a simple way to pass down the session:
1. Wrap Your Application with `LiveKitRoom`: This component handles connecting to the LiveKit server and sets up a context provider for you.
2. Access the Session with Hooks: In any child component, you can use the useRoomContext() hook from @livekit/components-react to get the session object.
Let me show you an example:
import { LiveKitRoom } from '@livekit/components-react';
import { useRoomContext } from '@livekit/components-react';
function App() {
return (
<LiveKitRoom serverUrl="wss://your-livekit-server.com" token="your-access-token" connect={true}>
<RoomView />
</LiveKitRoom>
);
}
function RoomView() {
const room = useRoomContext(); // Here you can access the session (room) object
return <div>Connected to room: {room?.name}</div>;
}
If you’d like, I’m here to guide you further with setting up the LiveKitRoom component or managing the session object. Just let me know how I can assist!
Sources: docs/index.html | components/session-view.tsx | Workflows | LiveKit Docsastonishing-horse-62951
09/26/2025, 5:07 PMtall-airline-16756
09/26/2025, 5:07 PMroom.interrupt() isn’t the right way to interrupt an agent in LiveKit. Instead, you’ll want to use session.interrupt(), which you can find on the AgentSession object. This method gently stops the agent’s current speech and updates the conversation context for you.
If you have the session object handy, you can simply call:
session.interrupt();
If you'd like, I’d be happy to help you make sure the session object is accessible within your React setup. Just let me know!
Sources: Agent speech and audio | LiveKit Docs | Turn detection and interruptions | LiveKit Docs | pipeline-tts/short_replies_only.py | Docs::Agentsastonishing-horse-62951
09/26/2025, 5:12 PMtall-airline-16756
09/26/2025, 5:13 PMsession.interrupt() in your <Chat> component, it’s important to make sure the session object is accessible. The LiveKitRoom component provides the room context to all child components, but the session object itself isn’t directly available through that context.
A helpful approach is to manage the session object separately and then pass it down to your <Chat> component. Here’s an example to guide you:
// In your main component
const session = createAgentSession(); // Initialize the session object
<LiveKitRoom
token={token}
serverUrl={import.meta.env.VITE_LIVEKIT_URL}
connect={true}
video={false}
audio={true}
>
<Chat session={session} />
</LiveKitRoom>
And then, inside your <Chat> component:
function Chat({ session }) {
const handleInterrupt = () => {
session.interrupt(); // Call session.interrupt()
};
return (
<div>
Chat component
<button onClick={handleInterrupt}>Interrupt Agent</button>
</div>
);
}
If you’d like, I’m here to help you further with managing the session object or integrating it smoothly into your setup. Just let me know!
Sources: src/components/LiveKitRoom.tsx | complex-agents/nova-sonic/nova-sonic-form-agent/components/session-view.tsx