Skip to content

Using LoopAgent causes Attribute Error in agent_transfer code #5863

@avlaskin

Description

@avlaskin

🔴 Required Information

Describe the Bug:
Any agent with LoopAgent will cause Attribute Error with ADK 2.1.0 when run using
runner API and root_agent is LlmAgent.

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:

  1. Install ADK==2.1.0
  2. Run agent where root_agent has on of the subagents - LoopAgent.
  3. See the error:
  File "/home/alex/env3/lib/python3.13/site-packages/google/adk/flows/llm_flows/agent_transfer.py", line 196, in _get_transfer_targets
    and peer_agent.mode not in ('single_turn', 'task')
        ^^^^^^^^^^^^^^^
  File "/home/alex/env3/lib/python3.13/site-packages/pydantic/main.py", line 1042, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'LoopAgent' object has no attribute 'mode'

Expected Behavior:
LoopAgent should work like in version 1.34.1.

Observed Behavior:
What actually happened? Include error messages or crash stack traces here.

Environment Details:

  • ADK Library Version (pip show google-adk): 2.1.0
  • Desktop OS:** Ubuntu/Debian
  • Python Version (python -V): 3.13

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-3.5-flash

Fix
Do hasattr check in the line 192 similar to the code above that.

  if not agent.disallow_transfer_to_peers:
    result.extend([
        peer_agent
        for peer_agent in agent.parent_agent.sub_agents
        if peer_agent.name != agent.name
        and (not hasattr(peer_agent, 'mode')    #  <-- Add guard here
             or peer_agent.mode not in ('single_turn', 'task'))
    ])

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions