mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Prevent agent_graph.py throwing when workflow agent is root agent
Partial fix for https://github.com/google/adk-python/issues/1170 TODOs: - UI rendering still has issue to match the event with the correct agent. - graph building needs further fix when there is a workflow agent in the tree. PiperOrigin-RevId: 767711701
This commit is contained in:
committed by
Copybara-Service
parent
7dbd8c6a5b
commit
4b1c218cbe
@@ -145,7 +145,7 @@ async def build_graph(
|
||||
return False
|
||||
|
||||
def build_cluster(child: graphviz.Digraph, agent: BaseAgent, name: str):
|
||||
if isinstance(agent, LoopAgent):
|
||||
if isinstance(agent, LoopAgent) and parent_agent:
|
||||
# Draw the edge from the parent agent to the first sub-agent
|
||||
draw_edge(parent_agent.name, agent.sub_agents[0].name)
|
||||
length = len(agent.sub_agents)
|
||||
@@ -162,7 +162,7 @@ async def build_graph(
|
||||
].name,
|
||||
)
|
||||
currLength += 1
|
||||
elif isinstance(agent, SequentialAgent):
|
||||
elif isinstance(agent, SequentialAgent) and parent_agent:
|
||||
# Draw the edge from the parent agent to the first sub-agent
|
||||
draw_edge(parent_agent.name, agent.sub_agents[0].name)
|
||||
length = len(agent.sub_agents)
|
||||
@@ -179,7 +179,7 @@ async def build_graph(
|
||||
) if currLength != length - 1 else None
|
||||
currLength += 1
|
||||
|
||||
elif isinstance(agent, ParallelAgent):
|
||||
elif isinstance(agent, ParallelAgent) and parent_agent:
|
||||
# Draw the edge from the parent agent to every sub-agent
|
||||
for sub_agent in agent.sub_agents:
|
||||
build_graph(child, sub_agent, highlight_pairs)
|
||||
|
||||
Reference in New Issue
Block a user