Skip to content

LlmAgent._run_async_impl resume path unconditionally sets end_of_agent=True #6017

@anmol0e

Description

@anmol0e

Bug

LlmAgent._run_async_impl resume path (lines 478-484 in llm_agent.py) unconditionally sets end_of_agent=True after a sub-agent returns, even when the sub-agent paused for a long-running tool call.

# Current code (llm_agent.py:474-484)
if agent_state is not None and (
    agent_to_transfer := self._get_subagent_to_resume(ctx)
):
    async with Aclosing(agent_to_transfer.run_async(ctx)) as agen:
        async for event in agen:
            yield event
    # BUG: unconditional — doesn't check if sub-agent paused
    ctx.set_agent_state(self.name, end_of_agent=True)
    yield self._create_agent_state_event(ctx)
    return

The LLM flow path (lines 486-505) correctly guards with should_pause checks. The resume path is missing the same guards.

Impact

Multi-step HITL workflows break when using Runner.run_async() natively (e.g. via adk web). After the first long-running tool round-trip through a sub-agent, the parent agent sets end_of_agent=True, causing the runner to early-return on subsequent resumes and silently dropping tool responses.

Reproduction

  1. Create a parent LlmAgent with a sub-agent
  2. Sub-agent has a long-running tool (e.g. is_long_running=True)
  3. Run through adk web or native Runner
  4. Complete first tool call → resume → sub-agent calls another tool
  5. Second tool result is silently dropped

Proposed Fix

Add should_pause guard to the resume path, matching the LLM flow path:

if agent_state is not None and (
    agent_to_transfer := self._get_subagent_to_resume(ctx)
):
    should_pause = False
    async with Aclosing(agent_to_transfer.run_async(ctx)) as agen:
        async for event in agen:
            yield event
            if ctx.should_pause_invocation(event):
                should_pause = True
    if should_pause:
        return
    ctx.set_agent_state(self.name, end_of_agent=True)
    yield self._create_agent_state_event(ctx)
    return

Environment

  • google-adk 1.33.0
  • Python 3.11

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions