Skip to content

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

Description

@khairulislam

馃敶 Required Information

Describe the Bug:
The dev UI can't draw the graph of an app whose root_agent is a Workflow. GET /dev/apps/{app_name}/graph returns 500 with AttributeError: 'Workflow' object has no attribute '_graph'.

The Workflow branch of build_graph reads agent._graph in three places (agent_graph.py#L206-L211), but Workflow has no such attribute. The compiled graph is the public pydantic field graph (_workflow.py#L158), which is what the rest of the workflow code uses. Pydantic models raise AttributeError for unknown names, so the request fails before anything is drawn.

Running the workflow is not affected, only the graph view. Nothing in tests/unittests/cli/test_agent_graph.py builds a Workflow, so this wasn't caught.

Steps to Reproduce:

  1. pip install google-adk==2.11.0
  2. Run the snippet below. (Or start adk web on any app whose root_agent is a Workflow and open /dev/apps/<app>/graph.)

Expected Behavior:
The graph is drawn from the workflow's nodes and edges, including routed back-edges such as retry loops. For the snippet: check -> check and check -> done.

Observed Behavior:

  File ".../google/adk/cli/agent_graph.py", line 200, in build_cluster
    elif isinstance(agent, Workflow) and agent._graph is not None:
  File ".../pydantic/main.py", line 1105, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'Workflow' object has no attribute '_graph'. Did you mean: 'graph'?

Over HTTP the same call gives 500 Internal Server Error from adk web.

Environment Details:

  • ADK Library Version (pip show google-adk): 2.11.0 (same lines in v2.12.0 and main b310c30)
  • Desktop OS: Windows 11
  • Python Version (python -V): 3.10.11

Model Information:

  • Are you using LiteLLM: Yes (not related, the snippet uses no model)
  • Which model is being used: N/A

馃煛 Optional Information

Regression:
The Workflow branch was added with agent._graph in 1622793 ("chore: switch main to v2.0.0 GA"), and Workflow has had graph and no _graph in the code I looked at since then. As far as I can tell it never worked on 2.x. I didn't run older releases.

Minimal Reproduction Code:

import asyncio

from google.adk import Event, Workflow
from google.adk.cli.agent_graph import get_agent_graph


def check(node_input: str):
  return Event(route="retry")


def done(node_input: str):
  return node_input


workflow = Workflow(
    name="root_agent",
    edges=[("START", check), (check, {"retry": check, "ok": done})],
)

print(asyncio.run(get_agent_graph(workflow, [])).source)

How often has this issue occurred?:

  • Always (100%)

Additional Context:
The fix is agent._graph -> agent.graph in those three places. With it, the dev UI graph for a plan/review/write workflow with retry back-edges is drawn correctly. I searched open and closed issues and PRs and didn't find this reported. Happy to send a PR with a regression test.

Activity

  1. added a commit that references this issue on Oct 14, 2026
    7af9e09
  2. surajksharma07 commented on Oct 14, 2026

    @surajksharma07
    Collaborator

    Confirmed the 500 on 2.11.0 @khairulislam and it's still there in 2.12.0 and on current main so this isn't fixed in a release yet.

    Until #7529 lands could you try adding if not hasattr(Workflow, "_graph"): Workflow._graph = property(lambda self: self.graph) in your agent.py and see if the graph renders for your plan/review/write workflow? It worked locally through adk web (500 -> 200 with the retry back-edges) but please check it against your actual app as well.

    On #7529: the change and the new test look right. The test fails on main and passes with your fix. Before review please run the full tests/unittests/cli suite once more and confirm the end-to-end check still holds after the merge from main.

  3. khairulislam commented on Oct 14, 2026

    @khairulislam
    Author

    That makes sense. I am updating the PR, will update once the test results are in.

  4. khairulislam commented on Oct 14, 2026

    @khairulislam
    Author

    Hi @surajksharma07 ,
    2. Yes, adding the hasattr(Workflow, "_graph") worked as a workaround for this error in my app as well.
    3. I have run the full test using pytest tests/unittests/cli -n 8 -q, results are in test_output.txt, shows 1460 passed, 5 skipped, 2 xfailed, 352 warnings in 169.99s (0:02:49).

  5. surajksharma07 commented on Oct 15, 2026

    @surajksharma07
    Collaborator

    Thanks for confirming the workaround on your app and for the full cli run, 1460 passed looks clean @khairulislam.

    Re-checked #7529 against today鈥檚 main (156f007): the diff is still just the 3 agent._graph -> agent.graph swaps plus the test, test_agent_graph.py passes 10/10 and the new test still fails on main without the fix. Your repro snippet now gives check -> check and check -> done as expected.

    Main is still broken so the workaround stays useful until this ships in a release. Nothing else needed from you and will flag #7529 for maintainer review.

  6. added
    core[Component] This issue is related to the core interface and implementation
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions