You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using LoopAgent causes Attribute Error in agent_transfer code #5863
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:
Install ADK==2.1.0
Run agent where root_agent has on of the subagents - LoopAgent.
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'))
])
Hi @avlaskin , Thanks for reporting this.
Could you please provide a minimal reproducible code snippet? This will allow us to investigate the issue accurately.
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
Activity
sanketpatil06 commentedon May 27, 2026
Hi @avlaskin , Thanks for reporting this.
Could you please provide a minimal reproducible code snippet? This will allow us to investigate the issue accurately.
AliMuhammadAslam commentedon May 30, 2026
Traced this to the peer-agent list comprehension in
_get_transfer_targets(agent_transfer.py). The sub-agent list already has anot hasattr(sub_agent, 'mode')guard, but the peer-agent list does the raw.modeaccess without it — soLoopAgent(which has nomodeattribute) raisesAttributeErrorthere.One-line fix adding the same
hasattrguard to the peer list: #5910avlaskin commentedon May 31, 2026
Exactly, the bug is obvious, the fix is there too. Please fix it, it blocks the v2.x adoption.
fix: guard peer agent mode access in agent transfer
fix: guard peer agent mode access in agent transfer