Skip to content

Using LoopAgent causes Attribute Error in agent_transfer code #5863

Closed

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%)

Activity

  1. added
    core[Component] This issue is related to the core interface and implementation
    on May 26, 2026
  2. added theissue type on May 26, 2026
  3. sanketpatil06 commented on May 27, 2026

    @sanketpatil06

    Hi @avlaskin , Thanks for reporting this.
    Could you please provide a minimal reproducible code snippet? This will allow us to investigate the issue accurately.

  4. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on May 27, 2026
  5. AliMuhammadAslam commented on May 30, 2026

    @AliMuhammadAslam
    Contributor

    Traced this to the peer-agent list comprehension in _get_transfer_targets (agent_transfer.py). The sub-agent list already has a not hasattr(sub_agent, 'mode') guard, but the peer-agent list does the raw .mode access without it — so LoopAgent (which has no mode attribute) raises AttributeError there.

    One-line fix adding the same hasattr guard to the peer list: #5910

  6. avlaskin commented on May 31, 2026

    @avlaskin
    Author

    Exactly, the bug is obvious, the fix is there too. Please fix it, it blocks the v2.x adoption.

  7. self-assigned this
    on Jun 2, 2026
  8. added a commit that references this issue on Jun 2, 2026
    bb16958
  9. added a commit that references this issue on Aug 11, 2026
    18b0431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions