fix(personaplex): fix connection and audio streaming#5106
Open
fix(personaplex): fix connection and audio streaming#5106
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Guard audio/text channel sends with ChanClosed suppression - Wrap recv_task message handlers in try/except to prevent single malformed frame from breaking the receive loop - Replace deprecated asyncio.get_event_loop() with get_running_loop() - Add response_id to GenerationCreatedEvent emissions - Add exponential backoff (1s -> 30s max) on reconnect instead of fixed 1s delay - Add 32 unit tests covering init, URL building, audio conversion, retry backoff, options, and data structures Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused imports in tests (ruff F401) - Fix import sorting (ruff I001) - Apply ruff format to realtime_model.py - Add __pdoc__ dict to realtime/__init__.py for docs generation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Preserve wss:// / https:// scheme for TLS deployments - Use logger.warning for unsupported dynamic instructions - Remove redundant length check on opus_bytes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename TestBuildWsUrl to TestSessionOptions with proper typed helper - Rename TestHandleTextToken to TestSpecialTokens to reflect actual scope - Wrap ResponseGeneration assertions in try/finally for channel cleanup Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added by upstream in AGT-2474 (#4622). PersonaPlex is full-duplex and does not support explicit user turn commits. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use ws:// scheme in all example URLs (README, docstrings) - Sync uv.lock after upstream merge Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
# Conflicts: # uv.lock
…r special tokens by raw byte
# Conflicts: # uv.lock
# Conflicts: # uv.lock
# Conflicts: # uv.lock
…hen pending future exists
…Error, move tests to root
…ve codecs to optional deps
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.
Summary
Fixes the PersonaPlex realtime plugin so it can successfully connect and stream audio with the PersonaPlex server. Based on @milanperovic's work in #1399.
sphn>=0.1.4,<0.2— The PersonaPlex server requires sphn<0.2. The 0.1.x and 0.2.x versions use incompatible wire formats and different APIs (append_pcm()/read_bytes()two-step in 0.1.x vs single return value in 0.2.x). Using the wrong version caused the server'sopus_reader.read_pcm()to returnNone, crashing the server-side opus decode loop.SAMPLE_RATE // 10 = 2400is not a valid Opus frame size and raises aValueError.is_alive()check during system prompt processing (~2-9s) that consumes incoming WS messages without feeding them to the Opus decoder. Audio sent during this phase is silently dropped. The official JS client only starts streaming mic audio after the handshake arrives. This change matches that behavior — audio frames buffer in the send channel during prompt processing and flush immediately when the handshake arrives._msg_chbetween connections so Opus-encoded frames from a previous session don't leak into a new connection with fresh codec state._encode_and_sendand_handle_audio_datato the two-step sphn 0.1.x API.