Skip to content

test(agent_transfer): add regression tests for non-LlmAgent peer transfers#6210

Open
AliMuhammadAslam wants to merge 2 commits into
google:mainfrom
AliMuhammadAslam:test/loop-agent-peer-transfer-regression
Open

test(agent_transfer): add regression tests for non-LlmAgent peer transfers#6210
AliMuhammadAslam wants to merge 2 commits into
google:mainfrom
AliMuhammadAslam:test/loop-agent-peer-transfer-regression

Conversation

@AliMuhammadAslam

Copy link
Copy Markdown

Closes #5863


Adds regression tests for the AttributeError that occurred when _get_transfer_targets iterated over peer agents without a mode attribute (e.g. LoopAgent, SequentialAgent, ParallelAgent).

The core fix — the hasattr guard in _get_transfer_targets — is already in main. These tests ensure the behaviour does not regress. As noted in #5910, the tests were not yet in main, so this is a test-only PR with no production code changes.

Five tests added to test_get_transfer_targets.py:

  • LoopAgent as a peer agent does not raise AttributeError
  • LoopAgent as a sub-agent does not raise AttributeError
  • SequentialAgent as a peer agent does not raise AttributeError
  • ParallelAgent as a peer agent does not raise AttributeError
  • LlmAgent with mode='single_turn' is correctly excluded from transfer targets (verifies the filtering logic, not just the guard)

All five use MockModel and real ADK agent objects — no external dependencies or mocking of internals.

…sfers

Regression tests for google#5863.

Before the hasattr guard was added to _get_transfer_targets, placing any
agent without a 'mode' attribute (LoopAgent, SequentialAgent, ParallelAgent)
alongside an LlmAgent in a parent's sub_agents raised:
  AttributeError: '<AgentType>' object has no attribute 'mode'

Five tests are added:
- LoopAgent as a peer agent does not raise
- LoopAgent as a sub-agent does not raise
- SequentialAgent as a peer agent does not raise
- ParallelAgent as a peer agent does not raise
- LlmAgent with mode='single_turn' is correctly excluded from targets
@rohityan rohityan added the core [Component] This issue is related to the core interface and implementation label Jul 1, 2026
@rohityan rohityan requested a review from xuanyang15 July 1, 2026 22:03
@rohityan rohityan added the needs review [Status] The PR/issue is awaiting review from the maintainer label Jul 1, 2026
@rohityan

rohityan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Hi @AliMuhammadAslam , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share.

@rohityan

rohityan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Hi @xuanyang15 , can you please review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using LoopAgent causes Attribute Error in agent_transfer code

2 participants