This guide explains how developers can configure event subscription interrupt modes to control how an AI Employee processes incoming events within a flow. By adjusting these settings, you manage flow execution priorities, queues, and cancellations for specific user personas.
Flow execution overview
In the Newo.ai platform, a flow functions as an execution queue for a specific user persona. When an AI Employee receives multiple events (such as speech start, speech end, or incoming messages), the flow processes them sequentially.
By default, the system adds every incoming event to the queue and executes them one by one. However, you often need to manipulate this queue to handle urgent interactions or discard irrelevant events. For example, if a user starts speaking while the agent is generating a response, you may want to interrupt the current action immediately.
Event subscription modes
You can configure the behavior of specific events using the Interrupt mode setting in the Builder. This setting determines how a new event interacts with the current execution queue.
The following table compares the three available modes:
Mode | Behavior | Use Case |
Queue | Default. Adds the new event to the end of the execution queue. The system executes the current event and all previously queued events before starting this one. | Standard conversation flow where every user input must be processed in order. |
Interrupt | Immediately stops the current execution and clears all pending events in the queue. The system then starts executing the new event immediately. | Urgent events like "User speech started" where the agent must stop talking to listen. |
Cancel | Checks if the queue is currently busy (executing an event or has pending items).
| Non-critical updates that should only happen if the agent is idle. |
Configuration examples
Queue mode
When interrupt_mode is set to queue, no data is lost. If an AI Employee is processing a long task and a user sends a message, that message waits in line.
Interrupt mode
When interrupt_mode is set to interrupt, the system prioritizes the new event.
Scenario: An agent is speaking.
Event: The user interrupts.
Result: The agent stops speaking immediately, clears any queued actions, and processes the speech.
Cancel mode
When interrupt_mode is set to cancel, the logic is effectively "reverse priority."
Scenario: The agent is processing a user message.
Event: A background status update event triggers with Cancel mode.
Result: The system detects the queue is not empty and discards the status update event. It does not interrupt the current message processing.
Handling interrupts within actions
While the Event subscription settings control when an interrupt signal is sent, specific actions within your flow determine how they respond to that signal.
Non-interruptible blocks
To guarantee that a specific sequence of actions completes regardless of interruptions, use non-interruptible blocks.
ποΈ NOTE
Any code placed between StartNonInterruptibleBlock and StopNonInterruptibleBlock executes atomically. Even if an interrupt signal is received, the system waits until the block finishes before processing the interruption.
GenStream interrupt modes
The GenStream action (used for streaming generated responses) has its own interrupt_mode parameter to handle signals received during generation.
none: The action ignores interrupt signals. It completes the full generation and streaming process before the flow allows an interruption.interrupt: The action stops generation and streaming immediately upon receiving an interrupt signal.interrupt_window: This mode creates a buffer period (defined byinterrupt_window_duration, e.g.,0.7seconds).Signal received inside window: The system stops generation and sends no information to the user. This prevents sending partial or irrelevant fragments.
Window passes: The system streams the full generated response to the user, ensuring they receive a complete answer even if an interrupt occurs later.
Sleep action
The Sleep action includes an interruptible boolean flag.
interruptible: true: If an interrupt signal is received during the sleep duration, the action stops immediately, and the flow processes the interrupt.interruptible: false: The action completes the full sleep duration before the system processes any pending interrupts.
