Skip to content

AttributeError in create_empty_state prevents adding current session to eval sets in ADK UI for Workflow-based agents #5995

@vannicktrinquier

Description

@vannicktrinquier

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:

  1. Define a root agent as an ADK Workflow:
from google.adk import Workflow
xxxx = Workflow(
    name="xxxx",
    edges=[("START", orchestrator_node)],
)
  1. Start the ADK web server:
uv run adk web .. --port 8081
  1. Go to the UI, create a new evaluation test
Image
  1. Add current session to eval set
Image
  1. Error is returned
Image
  1. 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%)

Metadata

Metadata

Assignees

Labels

web[Component] This issue will be transferred to adk-web

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions