Skip to content

docs(workflow): make the single-turn node example runnable - #7188

Closed
winter-street wants to merge 1 commit into
google:mainfrom
winter-street:docs/fix-single-turn-workflow-example
Closed

winter-street wants to merge 1 commit into
google:mainfrom
winter-street:docs/fix-single-turn-workflow-example

Conversation

@winter-street

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:

The single-turn example in this guide does not run. There are three separate issues in the same snippet:

  1. from google.adk.workflow import Workflow, build_nodegoogle/adk/workflow/__init__.py does not export build_node (it is not in __all__ or _LAZY_MEMBERS, and there is no workflow/build_node.py), so the import raises ImportError.
  2. writer_node = build_node(writer_agent) — unnecessary. Workflow wraps node-like objects in edges automatically, so the agent can be passed directly.
  3. (writer_node, "END")"END" is not a valid node-like value. Per build_node's docstring the accepted types are BaseNode, BaseAgent, BaseTool, a callable, or 'START', so this raises WorkflowConfigurationError.

Solution:

Pass the agent directly and drop the terminal edge, matching the other workflow guides:

from google.adk.agents import LlmAgent
from google.adk.workflow import Workflow

writer_agent = LlmAgent(
    name="writer",
    instruction="Write a short story about the input topic."
)

wf = Workflow(
    name="story_generator",
    edges=[
        ("START", writer_agent)
    ]
)

This follows the pattern in docs/guides/workflow/graph/index.md, function_node/index.md, base_node/index.md, and contributing/samples/workflows/agent_in_workflow/agent.py, none of which call build_node or use an "END" endpoint.

Testing Plan

Small documentation fix, so per the template this section is not required. For completeness, the verification performed:

  1. Parsed src/google/adk/workflow/__init__.py with ast and enumerated its module-level bindings and __all__: build_node is absent, Workflow is present.
  2. Confirmed no workflow/build_node.py or workflow/build_node/ submodule exists.
  3. Read build_node's docstring, which documents WorkflowConfigurationError for node-like values outside BaseNode/BaseAgent/BaseTool/callable/'START'.
  4. Scanned all 1327 from google.adk... import ... statements across docs/, contributing/, and .agents/, resolving submodule imports. This was the last broken import; the count is now zero.

The example imported `build_node` from `google.adk.workflow`, which does not
export it, so the snippet raised ImportError. `build_node` is also unnecessary:
`Workflow` wraps node-like objects in `edges` automatically. The trailing
`(writer_node, "END")` edge used a string that is not a valid node-like value,
which raises WorkflowConfigurationError.

Pass the agent directly and drop the terminal edge, matching the other workflow
guides.
copybara-service Bot pushed a commit that referenced this pull request Sep 21, 2026
@adk-bot

adk-bot commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Thank you @winter-street for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 06d4895.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Sep 21, 2026
@adk-bot adk-bot closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants