Skip to content

Commit 04f56d2

Browse files
committed
Fix issue #5349: Sub-agent with sequential LRO tools fails to resume.
Modified `_run_async_impl` in `llm_agent.py` to prevent premature `end_of_agent` marking when a sub-agent pauses for an LRO. Added `sub_agent_paused` tracking to ensure `end_of_agent=True` is only set if the sub-agent actually finished.
1 parent 4321de7 commit 04f56d2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/google/adk/agents/llm_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,15 @@ async def _run_async_impl(
474474
if agent_state is not None and (
475475
agent_to_transfer := self._get_subagent_to_resume(ctx)
476476
):
477-
sub_agent_paused = False
477+
sub_agent_paused = False # Track pause state
478478
async with Aclosing(agent_to_transfer.run_async(ctx)) as agen:
479479
async for event in agen:
480+
# Check if this event signals a pause (requires Bug 1 fix context)
480481
if ctx.should_pause_invocation(event):
481482
sub_agent_paused = True
482483
yield event
483484

485+
# Only mark as ended if it didn't pause
484486
if not sub_agent_paused:
485487
ctx.set_agent_state(self.name, end_of_agent=True)
486488
yield self._create_agent_state_event(ctx)

0 commit comments

Comments
 (0)