Repository navigation
AttributeError in create_empty_state prevents adding current session to eval sets in ADK UI for Workflow-based agents #5995
Description
Describe the Bug:
Seems that when running a Workflow-based agent, via the ADK 2.X development server, attempting to add a session to an evaluation set causes the server to crash with an AttributeError. This feature is important for end-users to create eval test case quickly from the UI and built confidence on their agent behavior.
Looks like the crash occurs because the state initialization utility (create_empty_state) assumes the root agent is a standard BaseAgent and attempts to traverse its child agents by accessing the .sub_agents attribute.
However, Workflow instances do not have a sub_agents attribute; their child agents (nodes) are stored under .graph.nodes.
Steps to Reproduce:
- Define a root agent as an ADK Workflow:
from google.adk import Workflow
xxxx = Workflow(
name="xxxx",
edges=[("START", orchestrator_node)],
)- Start the ADK web server:
uv run adk web .. --port 8081- Go to the UI, create a new evaluation test
- Add current session to eval set
- Error is returned
- From the adk console we can set the error is coming from those:
INFO: 127.0.0.1:50564 - "POST /dev/apps/xxxxx/eval_sets/eval_set_1/add_session HTTP/1.1" 500 Internal Server Error
...
See below for rest of logs.
Expected Behavior:
The empty state for the workflow agent is created successfully without any errors, allowing the session to be added to the evaluation set. And the current session can be added as eval case
Observed Behavior:
The server fails with a 500 Internal Server Error due to an unhandled AttributeError exception in _create_empty_state.
Environment Details:
- ADK Library Version (pip show google-adk): 2.1.0
- Desktop OS: macOS
- Python Version (python -V): Python 3.13.3
Model Information:
- Which model is being used: gemini-3.5-flash
Regression:
N/A (As Workflows are a new feature structure in ADK 2.x). But eval set were working as expected in ADK 1.X
Logs:
INFO: 127.0.0.1:50564 - "POST /dev/apps/xxxxx/eval_sets/eval_set_1/add_session HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "xxxxx/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 415, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.scope, self.receive, self.send
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
...
...
...
File "xxxxx/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 328, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xxxxx/.venv/lib/python3.13/site-packages/google/adk/cli/dev_server.py", line 863, in add_session_to_eval_set
initial_session_state = create_empty_state(root_agent)
File "xxxxx/.venv/lib/python3.13/site-packages/google/adk/cli/utils/state.py", line 54, in create_empty_state
_create_empty_state(agent, non_initialized_states)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xxxxx/.venv/lib/python3.13/site-packages/google/adk/cli/utils/state.py", line 26, in _create_empty_state
for sub_agent in agent.sub_agents:
^^^^^^^^^^^^^^^^
File "xxxxx/.venv/lib/python3.13/site-packages/pydantic/main.py", line 1042, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'Workflow' object has no attribute 'sub_agents'
Screenshots / Video:
See above
How often has this issue occurred?:
- Always (100%)
Activity
adk-bot commentedon Jun 6, 2026
GitHub Issue #5995 Analysis: AttributeError in create_empty_state prevents adding current session to eval sets in ADK UI for Workflow-based agents
Executive Summary
AttributeError: 'Workflow' object has no attribute 'sub_agents'in _create_empty_state. This occurs becausecreate_empty_stateassumes the root agent is a standardBaseAgentand directly accesses thesub_agentsattribute, whereasWorkflowobjects inherit fromBaseNodeand organize their sub-agents/nodes in.graph.nodes.Detailed Analysis
1. Root Cause Analysis ("What is broken?")
When a user clicks "Add current session to eval set" in the ADK UI, the dev server handles the POST request via the endpoint
add_session_to_eval_setin src/google/adk/cli/dev_server.py:L848-L880.To determine the initial state structure of the agentic application, it loads the root agent and calls:
In src/google/adk/cli/utils/state.py:L25-L36:
If the agent is a graph-based
Workflow, it is an instance ofBaseNoderather than a standardBaseAgentand does not define a.sub_agentsattribute. Accessingagent.sub_agentson line 26 yields:2. Existing Pull Requests ("Is there a linked PR that fixes this issue?")
3. Recommendation
_create_empty_stateshould be updated to safely traverse both standard hierarchical sub-agents (sub_agents) and workflow graph nodes (graph.nodes) using dynamic attribute fetching (getattr), avoiding circular imports and handling genericBaseNodehierarchies cleanly:getattroperates seamlessly for standard components and fixes the traversal crash forWorkflowmodels.Summary of work completed:
state.py,dev_server.py,api_server.py,app.py, and_workflow.py.adk-issue-analyzeread-only requirements.sanketpatil06 commentedon Jun 9, 2026
Hi @vannicktrinquier , Thanks for reporting this issue. We were able to reproduce it on our end.
We see that PR (#6001) has already been raised to address this issue and is currently under review. Would you mind checking it and letting us know if it resolves the issue for you?
vannicktrinquier commentedon Jun 16, 2026
Hi @sanketpatil06,
I have tested from my side by cloning the PR branch of #6001 and updated my current project to use the fixed code.
And I confirm, working from my side. I am able to save an evaluation as expected and content of file is relevant.
Thanks
fix: collect eval state from workflow nodes
fix: collect eval state from workflow nodes