8000 fix: Prevent agent_graph.py throwing when workflow agent is root agent · devevignesh/adk-python@4b1c218 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b1c218

Browse files
Jacksunweicopybara-github
authored andcommitted
fix: Prevent agent_graph.py throwing when workflow agent is root agent
Partial fix for google#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
1 parent 7dbd8c6 commit 4b1c218

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/google/adk/cli/agent_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def should_build_agent_cluster(tool_or_agent: Union[BaseAgent, BaseTool]):
145145
return False
146146

147147
def build_cluster(child: graphviz.Digraph, agent: BaseAgent, name: str):
148-
if isinstance(agent, LoopAgent):
148+
if isinstance(agent, LoopAgent) and parent_agent:
149149
# Draw the edge from the parent agent to the first sub-agent
150150
draw_edge(parent_agent.name, agent.sub_agents[0].name)
151151
length = len(agent.sub_agents)
@@ -162,7 +162,7 @@ def build_cluster(child: graphviz.Digraph, agent: BaseAgent, name: str):
162162
].name,
163163
)
164164
currLength += 1
165-
elif isinstance(agent, SequentialAgent):
165+
elif isinstance(agent, SequentialAgent) and parent_agent:
166166
# Draw the edge from the parent agent to the first sub-agent
167167
draw_edge(parent_agent.name, agent.sub_agents[0].name)
168168
length = len(agent.sub_agents)
@@ -179,7 +179,7 @@ def build_cluster(child: graphviz.Digraph, agent: BaseAgent, name: str):
179179
) if currLength != length - 1 else None
180180
currLength += 1
181181

182-
elif isinstance(agent, ParallelAgent):
182+
elif isinstance(agent, ParallelAgent) and parent_agent:
183183
# Draw the edge from the parent agent to every sub-agent
184184
for sub_agent in agent.sub_agents:
185185
build_graph(child, sub_agent, highlight_pairs)

0 commit comments

Comments
 (0)
0