Skip to content

Commit 3502d2b

Browse files
committed
fix
1 parent b1c5b66 commit 3502d2b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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)