docs: Update agent transfer related doc string and comments

This is to address https://github.com/google/adk-python/issues/1907

PiperOrigin-RevId: 783481177
This commit is contained in:
Xiang (Sean) Zhou
2025-07-15 14:50:33 -07:00
committed by Copybara-Service
parent 1a75848391
commit b1fa383e73
2 changed files with 11 additions and 15 deletions
+6 -11
View File
@@ -14,6 +14,8 @@
"""Implementation of AutoFlow."""
from __future__ import annotations
from . import agent_transfer
from .single_flow import SingleFlow
@@ -29,19 +31,12 @@ class AutoFlow(SingleFlow):
For peer-agent transfers, it's only enabled when all below conditions are met:
- The parent agent is also of AutoFlow;
- The parent agent is also an LlmAgent.
- `disallow_transfer_to_peer` option of this agent is False (default).
Depending on the target agent flow type, the transfer may be automatically
reversed. The condition is as below:
- If the flow type of the tranferee agent is also auto, transfee agent will
remain as the active agent. The transfee agent will respond to the user's
next message directly.
- If the flow type of the transfere agent is not auto, the active agent will
be reversed back to previous agent.
TODO: allow user to config auto-reverse function.
Depending on the target agent type, the transfer may be automatically
reversed. (see Runner._find_agent_to_run method for which agent will remain
active to handle next user message.)
"""
def __init__(self):
+5 -4
View File
@@ -446,7 +446,8 @@ class Runner:
root_agent: The root agent of the runner.
Returns:
The agent of the last message in the session or the root agent.
The agent to run. (the active agent that should reply to the latest user
message)
"""
# If the last event is a function response, should send this response to
# the agent that returned the corressponding function call regardless the
@@ -475,8 +476,8 @@ class Runner:
def _is_transferable_across_agent_tree(self, agent_to_run: BaseAgent) -> bool:
"""Whether the agent to run can transfer to any other agent in the agent tree.
This typically means all agent_to_run's parent through root agent can
transfer to their parent_agent.
This typically means all agent_to_run's ancestor can transfer to their
parent_agent all the way to the root_agent.
Args:
agent_to_run: The agent to check for transferability.
@@ -487,7 +488,7 @@ class Runner:
agent = agent_to_run
while agent:
if not isinstance(agent, LlmAgent):
# Only LLM-based Agent can provider agent transfer capability.
# Only LLM-based Agent can provide agent transfer capability.
return False
if agent.disallow_transfer_to_parent:
return False