Skip to content

Commit 1466ddb

Browse files
authored
Add Python 3.14 to the supported versions (openai#1961)
1 parent 4ba2e8a commit 1466ddb

File tree

4 files changed

+206
-150
lines changed

4 files changed

+206
-150
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ jobs:
5151
- "3.11"
5252
- "3.12"
5353
- "3.13"
54-
# TODO: enable this https://github.com/openai/openai-agents-python/pull/1961/
55-
# - "3.14"
54+
- "3.14"
5655
env:
5756
OPENAI_API_KEY: fake-for-tests
5857
steps:

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ requires-python = ">=3.9"
77
license = "MIT"
88
authors = [{ name = "OpenAI", email = "support@openai.com" }]
99
dependencies = [
10-
"openai>=2.2,<3",
11-
"pydantic>=2.10, <3",
10+
"openai>=2.6.1,<3",
11+
"pydantic>=2.12.3, <3",
1212
"griffe>=1.5.6, <2",
1313
"typing-extensions>=4.12.2, <5",
1414
"requests>=2.0, <3",
@@ -24,6 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.12",
2626
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
2728
"Operating System :: OS Independent",
2829
"Topic :: Software Development :: Libraries :: Python Modules",
2930
"License :: OSI Approved :: MIT License",

src/agents/run.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,19 @@ def run_sync(
720720
conversation_id = kwargs.get("conversation_id")
721721
session = kwargs.get("session")
722722

723-
return asyncio.get_event_loop().run_until_complete(
723+
# Python 3.14 no longer creates a default loop implicitly, so we inspect the running loop.
724+
try:
725+
loop = asyncio.get_running_loop()
726+
except RuntimeError:
727+
loop = None
728+
729+
if loop is not None:
730+
# This method is only expected to run when no loop is already active.
731+
raise RuntimeError(
732+
"AgentRunner.run_sync() cannot be called when an event loop is already running."
733+
)
734+
735+
return asyncio.run(
724736
self.run(
725737
starting_agent,
726738
input,

0 commit comments

Comments
 (0)