Repository navigation
voice-agents-python: the Python runtime holds frames during a resume, fails lost tool calls, counts unknown session frames - #3
Conversation
… tool calls, counts unknown session frames
|
Superseded by the render on voice-agents/render-b629252, which carries this change and the lane's later ones. |
| session._resuming = False | ||
| connection.sessions.pop(session.id, None) | ||
| if frame.error.code == "connection_full": |
There was a problem hiding this comment.
🟣 pre-existing, not blocking: pre-existing, partial fix: after a connection_full error, a session's audio and frames still go to the full connection, where its stream number may be another caller's. _error clears _resuming at agent.py:337 but leaves session._connection pointing at the full connection. The new send_audio guard (session.py:98) and the _send hold therefore stop working until the next connection resumes the session. Fix: keep the session in a held state until a resume on the new connection is answered. For example, leave _resuming True on the connection_full branch, so send_audio drops audio and _send keeps frames without sending them.
A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
_ready->_resume (agent.py:275-281) attaches a pending session to a new connection, sets session._connection to it and sets _resuming=True. Sent refuses with code connection_full. _error (agent.py:337-342) sets session._resuming=False, removes the session from connection.sessions and calls _open([session], 0.0), but session._connection still points at the full connection. Until the new connection sends connection.ready, the session's own task keeps running. During that gap, send_audio (session.py:98) skips the new _resuming guard and writes audio_frame(self.stream, ...) on the full connection using the stream number from the old connection. The diff's own comment says that number "may be another caller's" there, so the caller audio can reach a different call. say/clear/tool frames are also sent there rather than held for the replay. The base branch sent audio unconditionally, so this is the same behavior: the diff's fix covers the session.resume wait but not this window.
Verification: pre-existing. Trigger: Sent answers a session.resume with error code connection_full. _error (agent.py:337-342) never changes session._connection, so that still points at the full connection. send_audio (session.py:94-102) passes the new _resuming guard and puts this caller's audio on the full connection under a stale stream number. Base send_audio had no _resuming guard at all.
Rendered by the Voice Agents lane in sent-dm-sdk-pipeline from sent-dm-voice-protocol at
v0.2.0, after https://github.com/sentdm/sent-dm-sdk-pipeline/commit/aaf00190da3061263ebeaedc106afe29b1feb44d.What a reviewer checks: this repository's CI, the conformance job included, is green on this PR; the generated frames module and the runtime changed as the protocol or the template did; nothing release-please owns moved. Merging makes release-please open the release.