-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(phonic): reconnect after abnormal disconnects #6828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -386,6 +386,7 @@ def __init__(self, realtime_model: RealtimeModel) -> None: | |
|
|
||
| self._client = AsyncPhonic( | ||
| api_key=self._opts.api_key, | ||
| reconnect_conversation_on_abnormal_disconnect=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Tool results and audio sent while the connection is being restored are dropped without notice Messages such as tool results are handed to the connection while it is being re-established (via the client created at Reconnectable client no-ops sends while reconnecting, but the plugin already marked the tool call as answeredAll In Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| ) | ||
|
|
||
| self._socket: AsyncConversationsSocketClient | None = None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Voice sessions can go silent with no error when the provider connection drops for good
Automatic reconnection is turned on (
reconnect_conversation_on_abnormal_disconnect=Trueatlivekit-plugins/livekit-plugins-phonic/livekit/plugins/phonic/realtime/realtime_model.py:389) without handling the case where reconnecting ultimately fails, so a dropped call ends quietly instead of reporting a failure.Impact: When the connection cannot be restored, the agent simply stops talking and listening and nothing is notified, so the call hangs instead of erroring out or being recovered.
Silent break in the reconnectable socket iterator swallows abnormal-close errors
With the flag enabled,
client.conversations.connect()yields aReconnectableAsyncConversationsSocketClientinstead ofAsyncConversationsSocketClient(phonic SDKphonic/conversations/client.py:1258-1286). Its__aiter__catchesConnectionClosedand only re-raises when the close code is neither normal (1000) nor "reconnectable" (1006/1012/1001-restarting); for a 1006 abnormal close where reconnect is impossible (noconversation_idyet) or exhausted (10 attempts), it justbreaks without raising (phonic/conversations/reconnectable_socket_client.py:193-206,155-191).The plugin's
_recv_task(livekit-plugins/livekit-plugins-phonic/livekit/plugins/phonic/realtime/realtime_model.py:956-995) therefore returns normally. In_main_task(...:926-938)recv_taskisdonewith no exception, so no_emit_error(..., recoverable=True)is raised; the code cancels the peers, closes the socket and the current generation, and the session ends without surfacing any error toAgentSession.Before this change, the plain socket iterator propagated
ConnectionClosedErroron abnormal closes, so the plugin logged and emitted a recoverable error.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.