Skip to content

fix(cli): read Workflow.graph when drawing the dev UI graph - #7529

Open
khairulislam wants to merge 6 commits into
google:mainfrom
khairulislam:fix/agent-graph-workflow-private-graph
Open

khairulislam wants to merge 6 commits into
google:mainfrom
khairulislam:fix/agent-graph-workflow-private-graph

Conversation

@khairulislam

Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
build_graph() reads agent._graph for Workflow agents, but Workflow only has the public field graph. Any Workflow root agent makes GET /dev/apps/{app_name}/graph return 500, so the dev UI cannot draw the workflow:

File "google/adk/cli/agent_graph.py", line 200, in build_cluster
    elif isinstance(agent, Workflow) and agent._graph is not None:
AttributeError: 'Workflow' object has no attribute '_graph'. Did you mean: 'graph'?

Running the workflow is not affected. Present in v2.11.0, v2.12.0 and main.

Solution:
Use agent.graph (3 occurrences). No other change.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added test_build_graph_workflow_draws_nodes_and_edges_from_its_graph to tests/unittests/cli/test_agent_graph.py: a Workflow with an agent, function nodes, a retry back-edge and a DEFAULT_ROUTE edge. It fails on main with the AttributeError above and passes with this change.

$ pytest tests/unittests/cli/test_agent_graph.py -q
10 passed

Manual End-to-End (E2E) Tests:

adk web with a Workflow root agent (plan -> review -> write -> review, each review looping back on a retry route): GET /dev/apps/<app>/graph returns 500 on main. With this change it returns 200 and the DOT source includes the nodes and the retry back-edges (review_outline -> BlogPlanner, review_post -> BlogWriter).

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

build_graph() read agent._graph, but Workflow stores its compiled graph in the
public `graph` field. Any Workflow root agent therefore raised
AttributeError: 'Workflow' object has no attribute '_graph', so
/dev/apps/{app}/graph returned a 500 and the dev UI could not draw the graph.

Fixes google#7528
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@khairulislam
khairulislam force-pushed the fix/agent-graph-workflow-private-graph branch from 67332fd to b94952b Compare October 14, 2026 15:25
@khairulislam

Copy link
Copy Markdown
Author

Test output from pytest tests/unittests/cli -n 8 -q : test_output.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev UI graph fails for Workflow root agents: build_graph reads agent._graph, which doesn't exist

2 participants