logo
On this page

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 MethodDescription
Voice InterruptionWhen 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 InterruptionThrough API, you can directly interrupt the AI agent's current content

Common Scenarios

Voice Call ModeInterruption CombinationCommon 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.

ParameterTypeRequiredDescription
InterruptModeNumberNoMode for voice interruption during agent's response:
  • 0: Voice interruption enabled
  • 1: Voice interruption disabled (ASR starts after AI output (TTS playback) completes)
Default is 0 if not set.

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

1
Configure Callback Address

Contact ZEGOCLOUD technical support to configure the address for receiving AI Agent backend callbacks.

2
Enable Callback Reception

When creating an agent instance, set the request parameter CallbackConfig.Interrupted to 1.

3
Receive Callbacks

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:

Untitled
{
    "AppId": 123456789,
    "Nonce": "abcdd22113",
    "Timestamp": 1747033950524,
    "Sequence": 1921825797275873300,
    "Signature": "XXXXXXX",
    "Event": "Interrupted",
    "RoomId": "90000001237",
    "AgentInstanceId": "1921825671047294976",
    "AgentUserId": "apitest689_agent",
    "Data": {
        "Round": 1481651956,
        "Reason": 1
    }
}
1
Copied!

The Reason parameter is explained below:

ParameterTypeDescription
ReasonNumberInterruption reason:

Previous

Configure ASR Hot Word

Next

Speech Segmentation Control