Skip to content

Commit 7b707ce

Browse files
DeanChensjcopybara-github
authored andcommitted
chore: Simplfiy the parallel agent py version handling logic
PiperOrigin-RevId: 811992425
1 parent c984b9e commit 7b707ce

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/google/adk/agents/parallel_agent.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,17 @@ async def _run_async_impl(
188188
pause_invocation = False
189189
try:
190190
# TODO remove if once Python <3.11 is no longer supported.
191-
if sys.version_info >= (3, 11):
192-
async with Aclosing(_merge_agent_run(agent_runs)) as agen:
193-
async for event in agen:
194-
yield event
195-
if ctx.should_pause_invocation(event):
196-
pause_invocation = True
197-
else:
198-
async with Aclosing(_merge_agent_run_pre_3_11(agent_runs)) as agen:
199-
async for event in agen:
200-
yield event
201-
if ctx.should_pause_invocation(event):
202-
pause_invocation = True
191+
merge_func = (
192+
_merge_agent_run
193+
if sys.version_info >= (3, 11)
194+
else _merge_agent_run_pre_3_11
195+
)
196+
197+
async with Aclosing(merge_func(agent_runs)) as agen:
198+
async for event in agen:
199+
yield event
200+
if ctx.should_pause_invocation(event):
201+
pause_invocation = True
203202

204203
if pause_invocation:
205204
return

0 commit comments

Comments
 (0)