fix: serialize PiVoice RPC turns - #175
Draft
0Downtime wants to merge 1 commit into
Draft
Conversation
Correlate new_session acknowledgements by request ID and surface reset failures instead of accepting stale responses. Co-Authored-By: OpenAI Codex <noreply@openai.com>
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
new_session-> prompt ->agent_end)new_sessionacknowledgements by request IDWhy
PiVoiceLLMowns one long-livedPiClientand one response queue, while a xiaozhi connection uses a five-workerThreadPoolExecutorand submitsconn.chatjobs asynchronously. Two overlapping turns could therefore read from the same ordered Pi RPC stream, allowing one caller to consume another caller's frames.The reset path also accepted the first
new_sessionresponse regardless of request ID orsuccess. A stale failed response could complete the reset early and leave the correct acknowledgement queued for the next operation.A deterministic regression run against unmodified
mainreproduced the overlap (second turn must wait: two active prompts instead of one). The same test passes with this lock.Impact
Concurrent or rapidly interrupted voice turns now wait for the active Pi transaction to reach
agent_end. Reset acknowledgements cannot be confused with stale responses, and explicit Pi reset failures are logged through the provider's existing fallback path.Validation
ruff check .git diff --checkNo live-device claim is made; this PR validates the reachable race with a deterministic concurrency harness.