Skip to content

Commit f4519df

Browse files
authored
Merge branch 'main' into add-dapr-session
2 parents 528b6af + c422030 commit f4519df

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ jobs:
4141

4242
tests:
4343
runs-on: ubuntu-latest
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
python-version:
48+
- "3.10"
49+
- "3.11"
50+
- "3.12"
51+
- "3.13"
52+
# TODO: enable this https://github.com/openai/openai-agents-python/pull/1961/
53+
# - "3.14"
4454
env:
4555
OPENAI_API_KEY: fake-for-tests
4656
steps:
@@ -50,6 +60,7 @@ jobs:
5060
uses: astral-sh/setup-uv@v5
5161
with:
5262
enable-cache: true
63+
python-version: ${{ matrix.python-version }}
5364
- name: Install dependencies
5465
run: make sync
5566
- name: Run tests with coverage
@@ -71,7 +82,7 @@ jobs:
7182
- name: Build docs
7283
run: make build-docs
7384

74-
old_versions:
85+
old_version_tests:
7586
runs-on: ubuntu-latest
7687
env:
7788
OPENAI_API_KEY: fake-for-tests

src/agents/realtime/openai_realtime.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ def remove_listener(self, listener: RealtimeModelListener) -> None:
266266

267267
async def _emit_event(self, event: RealtimeModelEvent) -> None:
268268
"""Emit an event to the listeners."""
269-
for listener in self._listeners:
269+
# Copy list to avoid modification during iteration
270+
for listener in list(self._listeners):
270271
await listener.on_event(event)
271272

272273
async def _listen_for_messages(self):
@@ -431,7 +432,7 @@ async def _send_interrupt(self, event: RealtimeModelSendInterrupt) -> None:
431432
and session.audio is not None
432433
and session.audio.input is not None
433434
and session.audio.input.turn_detection is not None
434-
and session.audio.input.turn_detection.interrupt_response is True,
435+
and session.audio.input.turn_detection.interrupt_response is True
435436
)
436437
if not automatic_response_cancellation_enabled:
437438
await self._cancel_response()
@@ -516,6 +517,10 @@ async def close(self) -> None:
516517
self._websocket = None
517518
if self._websocket_task:
518519
self._websocket_task.cancel()
520+
try:
521+
await self._websocket_task
522+
except asyncio.CancelledError:
523+
pass
519524
self._websocket_task = None
520525

521526
async def _cancel_response(self) -> None:
@@ -616,7 +621,7 @@ async def _handle_ws_event(self, event: dict[str, Any]):
616621
and session.audio is not None
617622
and session.audio.input is not None
618623
and session.audio.input.turn_detection is not None
619-
and session.audio.input.turn_detection.interrupt_response is True,
624+
and session.audio.input.turn_detection.interrupt_response is True
620625
)
621626
if not automatic_response_cancellation_enabled:
622627
await self._cancel_response()

0 commit comments

Comments
 (0)