Skip to content

fix(voice): finish STT event handling after listener errors - #4170

Merged
seratch merged 2 commits into
mainfrom
fix/stt-session-error-cleanup
Aug 4, 2026
Merged

fix(voice): finish STT event handling after listener errors#4170
seratch merged 2 commits into
mainfrom
fix/stt-session-error-cleanup

Conversation

@seratch

@seratch seratch commented Aug 4, 2026

Copy link
Copy Markdown
Member

This pull request fixes a Python 3.10 and 3.11 test slowdown caused by streamed STT error cleanup waiting for the event inactivity timeout.

The websocket listener now always notifies the event consumer when it exits, including error and cancellation paths. This allows the event-processing task to finish promptly while preserving the existing terminal STTWebsocketConnectionError behavior. The regression test verifies that server errors emit the websocket completion marker and leave the event-processing task finished.

@seratch seratch added this to the 0.19.x milestone Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5f6e8f872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/voice/models/openai_stt.py
@seratch
seratch enabled auto-merge (squash) August 4, 2026 06:47
@seratch
seratch merged commit d89fdde into main Aug 4, 2026
9 checks passed
@seratch
seratch deleted the fix/stt-session-error-cleanup branch August 4, 2026 06:51
abhay-codes07 added a commit to abhay-codes07/openai-agents-python that referenced this pull request Aug 5, 2026
Three streaming dispatchers hand user events to a background task and then
wait for asyncio.Queue.join() before returning. Each dispatcher catches only
Exception, so a handler raising a BaseException -- CancelledError being the
realistic one, from a timeout or cancellation inside the callback -- kills the
consumer. The outstanding task_done() calls can then never arrive and join()
blocks forever, hanging the run with no error and no timeout.

In every case join() is also redundant. The sentinel is queued last and the
consumer only returns after consuming it, so awaiting the consumer task
already implies every event was handled, and it surfaces a dead consumer
instead of waiting on it.

- Agent.as_tool(on_stream=...) hung the tool invocation.
- Codex tool _consume_events() hung and left its tracing spans unfinished,
  because the span cleanup runs after the join.
- The sandbox memory manager flush hung before its phase-two consolidation.

Same failure shape as the STT listener fix in openai#4170.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant