Interrupt Agent
Different scenarios require different ways to interrupt the AI agent's speech. Currently, two interruption methods are supported and can be used in combination.
Interruption Method | Description |
---|---|
Voice Interruption | When voice interruption is enabled, the AI agent continuously monitors the user's speech status and recognizes speech content while speaking. If the user starts speaking, the AI agent stops speaking (stopping the current LLM request and TTS request) and starts the next round of response. If voice interruption is disabled, the next round will only begin after the AI agent finishes speaking. |
Manual Interruption | Through API, you can directly interrupt the AI agent's current content |
Common Scenarios
Voice Call Mode | Interruption Combination | Common Scenarios |
---|---|---|
Natural Voice Chat | ✅Enable Voice Interruption ❌No Manual Interruption | AI Virtual Companion AI Voice Assistant AI Customer Service |
Push-to-talk Mode | ❌Disable Voice Interruption ✅Use Manual Interruption | Noisy Exhibition Environment Brief Speeches in Seminars Time-limited Speaking in Social Deduction Games |
Implementation Steps
Enable or Disable Voice Interruption
When creating an agent instance, you can control voice interruption by setting the AdvancedConfig.InterruptMode
parameter.
Parameter | Type | Required | Description |
---|---|---|---|
InterruptMode | Number | No | Mode for voice interruption during agent's response:
|
Manual Interruption
Call the InterruptAgentInstance API with the AgentInstanceId
returned from the Create Agent Instance API to immediately interrupt the AI agent's speech.
Receive Agent Interruption Event Notifications
Contact ZEGOCLOUD technical support to configure the address for receiving AI Agent backend callbacks.
When creating an agent instance, set the request parameter CallbackConfig.Interrupted
to 1.
When the agent is interrupted, the AI Agent backend will send an interruption event notification (Event
is Interrupted
) to the configured address. Here's an example:
{
"AppId": 123456789,
"Nonce": "abcdd22113",
"Timestamp": 1747033950524,
"Sequence": 1921825797275873300,
"Signature": "XXXXXXX",
"Event": "Interrupted",
"RoomId": "90000001237",
"AgentInstanceId": "1921825671047294976",
"AgentUserId": "apitest689_agent",
"Data": {
"Round": 1481651956,
"Reason": 1
}
}
The Reason
parameter is explained below:
Parameter | Type | Description |
---|---|---|
Reason | Number | Interruption reason:
|