File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 14
14
15
15
"""Implementation of AutoFlow."""
16
16
17
+ from __future__ import annotations
18
+
17
19
from . import agent_transfer
18
20
from .single_flow import SingleFlow
19
21
@@ -29,19 +31,12 @@ class AutoFlow(SingleFlow):
29
31
30
32
For peer-agent transfers, it's only enabled when all below conditions are met:
31
33
32
- - The parent agent is also of AutoFlow;
34
+ - The parent agent is also an LlmAgent.
33
35
- `disallow_transfer_to_peer` option of this agent is False (default).
34
36
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.)
45
40
"""
46
41
47
42
def __init__ (self ):
Original file line number Diff line number Diff line change @@ -446,7 +446,8 @@ def _find_agent_to_run(
446
446
root_agent: The root agent of the runner.
447
447
448
448
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)
450
451
"""
451
452
# If the last event is a function response, should send this response to
452
453
# the agent that returned the corressponding function call regardless the
@@ -475,8 +476,8 @@ def _find_agent_to_run(
475
476
def _is_transferable_across_agent_tree (self , agent_to_run : BaseAgent ) -> bool :
476
477
"""Whether the agent to run can transfer to any other agent in the agent tree.
477
478
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 .
480
481
481
482
Args:
482
483
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:
487
488
agent = agent_to_run
488
489
while agent :
489
490
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.
491
492
return False
492
493
if agent .disallow_transfer_to_parent :
493
494
return False
You can’t perform that action at this time.
0 commit comments