fix: add callback_interruption to Conversation/AsyncConversation - #843
Open
SomSamantray wants to merge 3 commits into
Open
fix: add callback_interruption to Conversation/AsyncConversation#843SomSamantray wants to merge 3 commits into
SomSamantray wants to merge 3 commits into
Conversation
added 3 commits
August 11, 2026 18:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Conversation/AsyncConversationexpose a callback for every WebSocket event type the wrapper dispatches —agent_response,user_transcript,audio_alignment, etc. — exceptinterruption. When an interruption event arrived, the wrapper only calledaudio_interface.interrupt()internally; there was no way for a caller to observe the event, and text-only (noaudio_interface) integrations couldn't observe it at all.Closes #672.
Fix
Added an optional
callback_interruptionparameter to bothConversationandAsyncConversation, following the same pattern already used for the other callbacks. It fires with a newInterruptionEvent(event_id, reason)dataclass (mirroring the existingAudioEventAlignmentpattern) in addition to the existingaudio_interface.interrupt()call, in both the sync and async paths.Added test coverage for both paths.
Note
Low Risk
Backward-compatible optional callback and additive dataclass; existing callers unchanged when the callback is omitted.
Overview
Adds optional
callback_interruptionon syncConversationandAsyncConversationso apps can observe WebSocket interruption events, including text-only sessions without an audio interface.Introduces
InterruptionEvent(event_id, optionalreason) and wires interruption handling to still callaudio_interface.interrupt()when present, then invoke the callback if set. Sync and async message paths share the same behavior.Adds unit tests for callback invocation with/without audio, default
Nonecallback, and missingreasonon the wire event.Reviewed by Cursor Bugbot for commit 795971e. Bugbot is set up for automated code reviews on this repo. Configure here.