Skip to content

Commit b1fa383

Browse files
seanzhougooglecopybara-github
authored andcommitted
docs: Update agent transfer related doc string and comments
This is to address #1907 PiperOrigin-RevId: 783481177
1 parent 1a75848 commit b1fa383

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/google/adk/flows/llm_flows/auto_flow.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
"""Implementation of AutoFlow."""
1616

17+
from __future__ import annotations
18+
1719
from . import agent_transfer
1820
from .single_flow import SingleFlow
1921

@@ -29,19 +31,12 @@ class AutoFlow(SingleFlow):
2931
3032
For peer-agent transfers, it's only enabled when all below conditions are met:
3133
32-
- The parent agent is also of AutoFlow;
34+
- The parent agent is also an LlmAgent.
3335
- `disallow_transfer_to_peer` option of this agent is False (default).
3436
35-
Depending on the target agent flow type, the transfer may be automatically
36-
reversed. The condition is as below:
37-
38-
- If the flow type of the tranferee agent is also auto, transfee agent will
39-
remain as the active agent. The transfee agent will respond to the user's
40-
next message directly.
41-
- If the flow type of the transfere agent is not auto, the active agent will
42-
be reversed back to previous agent.
43-
44-
TODO: allow user to config auto-reverse function.
37+
Depending on the target agent type, the transfer may be automatically
38+
reversed. (see Runner._find_agent_to_run method for which agent will remain
39+
active to handle next user message.)
4540
"""
4641

4742
def __init__(self):

src/google/adk/runners.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ def _find_agent_to_run(
446446
root_agent: The root agent of the runner.
447447
448448
Returns:
449-
The agent of the last message in the session or the root agent.
449+
The agent to run. (the active agent that should reply to the latest user
450+
message)
450451
"""
451452
# If the last event is a function response, should send this response to
452453
# the agent that returned the corressponding function call regardless the
@@ -475,8 +476,8 @@ def _find_agent_to_run(
475476
def _is_transferable_across_agent_tree(self, agent_to_run: BaseAgent) -> bool:
476477
"""Whether the agent to run can transfer to any other agent in the agent tree.
477478
478-
This typically means all agent_to_run's parent through root agent can
479-
transfer to their parent_agent.
479+
This typically means all agent_to_run's ancestor can transfer to their
480+
parent_agent all the way to the root_agent.
480481
481482
Args:
482483
agent_to_run: The agent to check for transferability.
@@ -487,7 +488,7 @@ def _is_transferable_across_agent_tree(self, agent_to_run: BaseAgent) -> bool:
487488
agent = agent_to_run
488489
while agent:
489490
if not isinstance(agent, LlmAgent):
490-
# Only LLM-based Agent can provider agent transfer capability.
491+
# Only LLM-based Agent can provide agent transfer capability.
491492
return False
492493
if agent.disallow_transfer_to_parent:
493494
return False

0 commit comments

Comments
 (0)