Skip to content

fix: collect eval state from workflow nodes#6001

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/workflow-empty-state
Open

fix: collect eval state from workflow nodes#6001
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/workflow-empty-state

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

Fixes #5995.

create_empty_state() only walked sub_agents, so graph-based Workflow roots crashed when the dev server tried to add the current session to an eval set. Workflow children live in workflow.graph.nodes, not sub_agents.

This updates the state traversal to:

  • keep the existing sub_agents walk for normal agents
  • also walk graph.nodes for Workflow-style roots and nested graph nodes
  • track visited objects so shared graph/agent nodes are not processed repeatedly

Testing

python -m pytest tests\unittests\cli\utils\test_state.py -q
python -m py_compile src\google\adk\cli\utils\state.py tests\unittests\cli\utils\test_state.py
python -m pyink --check src\google\adk\cli\utils\state.py tests\unittests\cli\utils\test_state.py
git diff --check

@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Jun 7, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 7, 2026

I have successfully performed a comprehensive, read-only analysis of Pull Request #6001 and its related issue #5995.

I have created a premium, structured review report for you. You can read the full, detailed analysis in the newly generated artifact:
👉 pr_analysis_report.md

Key Highlights & Summary of Findings

  1. Google CLA Compliance Gate (Passed):
    • Verified that the contributor @he-yufeng has successfully signed and passed the standard Google CLA check (re-verified via standard GitHub checks status).
  2. Root Cause Resolved:
    • The state initialization utility create_empty_state() in state.py previously assumed the root agent is a standard BaseAgent and traversed child elements via .sub_agents.
    • In graph-based Workflows (introduced in ADK 2.x), child nodes live in .graph.nodes, which produced an AttributeError and crashed the ADK Dev Server with a 500 Internal Server Error when developers attempted to save active sessions to evaluation sets.
    • The PR resolves this systematically by dynamically querying and traversing both sub_agents and graph.nodes. It also elegantly handles cyclic or shared node graphs using an object identity cycle-tracker (visited set).
  3. Principles & Style Compliance (Pass with Nits):
    • Quality: The solution is robust and does not introduce any breaking changes to the public API namespace.
    • Testing: Excellent behavior-focused test coverage added in the new unit test file, utilizing 100% real components (Workflow, LlmAgent, and edge bounds) without mocking.
    • Styling/Typing Nits:
      • Nit 1: The new test file tests/unittests/cli/utils/test_state.py is missing the mandatory from __future__ import annotations header import.
      • Nit 2: Parameter typing in create_empty_state(...) was relaxed to Any instead of leveraging ADK's BaseNode interface (the common ancestor for both BaseAgent and Workflow), which could be annotated more strongly.

Next Steps and Recommendations

  • Recommendation: Approve with Nits. The patch is high-impact, low-risk, and handles DAG structures extremely cleanly. We can request

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

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants