Describe the bug
Multiple Python sample codes across the Graph Workflows documentation (docs/graphs/) contain code discrepancies, syntax errors, and API mismatches with the surrounding explanatory text and the ADK Python 2.0 runtime:
-
docs/graphs/routes.md (Loop and escalation exit):
- The section describes creating iterative loops with back-edges and exit termination routes in a
Workflow. However, the Python code snippet is an exact duplicate of the forward branching router and contains no loop, no back-edge, and no exit condition.
-
docs/graphs/human-input.md (Tool-confirmation: approval prompts in LLM agents):
- The text explicitly introduces LLM agent-level Tool Confirmation (
FunctionTool / tool_context.request_confirmation) and contrasts it with standalone graph HITL nodes. However, the Python sample code shows an initial_prompt workflow function node yielding RequestInput, which is a graph-level HITL pause rather than tool confirmation.
-
docs/graphs/data-handling.md (Access structured data in agents):
- The text and code introduce an imaginary angle-bracket syntax (
<CityTime.time_info from lookup_time_function>) that does not exist in ADK Python. Furthermore, START is unquoted and unimported, and city_generator_agent is referenced without definition.
-
docs/graphs/dynamic.md (Loop route):
- The
code_workflow function contains both yield Event(...) and return code within an async def, causing Python to raise a SyntaxError: 'return' with value in async generator. It is also missing rerun_on_resume=True.
-
docs/graphs/dynamic.md (Nodes / FunctionNode wrapper):
FunctionNode(my_function_node, ...) passes the function positionally, but FunctionNode.__init__ enforces keyword-only arguments (def __init__(self, *, func: Callable, ...)), raising a TypeError at runtime.
-
docs/graphs/data-handling.md (Session state and state scopes):
- Omitted necessary imports (
Context, Event, Workflow, Content), causing NameError when executing the snippet.
To Reproduce
Steps to reproduce the behavior:
- Navigate to the following documentation pages:
docs/graphs/routes.md#loop-and-escalation-exit
docs/graphs/human-input.md#tool-confirmation-approval-prompts-in-llm-agents
docs/graphs/data-handling.md#access-structured-data-in-agents
docs/graphs/dynamic.md#loop-route
docs/graphs/dynamic.md#node
- Compare the code samples with the surrounding text descriptions and run the sample codes in a standard ADK Python 2.0 environment.
- Observe syntax errors (
SyntaxError), runtime exceptions (TypeError, NameError), and functional mismatches with the text.
Expected behavior
routes.md should demonstrate an actual loop workflow with a back-edge and terminal route.
human-input.md should demonstrate static and dynamic tool confirmation (FunctionTool(..., require_confirmation=True) and tool_context.request_confirmation(...)).
data-handling.md should demonstrate standard structured data input schemas (input_schema=CityTime) with valid prompt instructions without phantom syntax.
dynamic.md should demonstrate a valid programmatic while loop that returns the result cleanly without mixing generator yield and return value in the same function, and include rerun_on_resume=True.
dynamic.md should use keyword arguments for FunctionNode(func=...).
- All snippets should be self-contained with complete imports.
Screenshots
N/A (Code and documentation issue)
Versions
- OS: macOS / Linux / Windows
- ADK version: 2.0.0
- Python version: 3.10+
Additional context
A complete patch fixing all 6 issues is prepared as attachment
fix-graphs-docs-code-samples.patch
Describe the bug
Multiple Python sample codes across the Graph Workflows documentation (
docs/graphs/) contain code discrepancies, syntax errors, and API mismatches with the surrounding explanatory text and the ADK Python 2.0 runtime:docs/graphs/routes.md(Loop and escalation exit):Workflow. However, the Python code snippet is an exact duplicate of the forward branching router and contains no loop, no back-edge, and no exit condition.docs/graphs/human-input.md(Tool-confirmation: approval prompts in LLM agents):FunctionTool/tool_context.request_confirmation) and contrasts it with standalone graph HITL nodes. However, the Python sample code shows aninitial_promptworkflow function node yieldingRequestInput, which is a graph-level HITL pause rather than tool confirmation.docs/graphs/data-handling.md(Access structured data in agents):<CityTime.time_info from lookup_time_function>) that does not exist in ADK Python. Furthermore,STARTis unquoted and unimported, andcity_generator_agentis referenced without definition.docs/graphs/dynamic.md(Loop route):code_workflowfunction contains bothyield Event(...)andreturn codewithin anasync def, causing Python to raise aSyntaxError: 'return' with value in async generator. It is also missingrerun_on_resume=True.docs/graphs/dynamic.md(Nodes / FunctionNode wrapper):FunctionNode(my_function_node, ...)passes the function positionally, butFunctionNode.__init__enforces keyword-only arguments (def __init__(self, *, func: Callable, ...)), raising aTypeErrorat runtime.docs/graphs/data-handling.md(Session state and state scopes):Context,Event,Workflow,Content), causingNameErrorwhen executing the snippet.To Reproduce
Steps to reproduce the behavior:
docs/graphs/routes.md#loop-and-escalation-exitdocs/graphs/human-input.md#tool-confirmation-approval-prompts-in-llm-agentsdocs/graphs/data-handling.md#access-structured-data-in-agentsdocs/graphs/dynamic.md#loop-routedocs/graphs/dynamic.md#nodeSyntaxError), runtime exceptions (TypeError,NameError), and functional mismatches with the text.Expected behavior
routes.mdshould demonstrate an actual loop workflow with a back-edge and terminal route.human-input.mdshould demonstrate static and dynamic tool confirmation (FunctionTool(..., require_confirmation=True)andtool_context.request_confirmation(...)).data-handling.mdshould demonstrate standard structured data input schemas (input_schema=CityTime) with valid prompt instructions without phantom syntax.dynamic.mdshould demonstrate a valid programmaticwhileloop that returns the result cleanly without mixing generatoryieldandreturn valuein the same function, and includererun_on_resume=True.dynamic.mdshould use keyword arguments forFunctionNode(func=...).Screenshots
N/A (Code and documentation issue)
Versions
Additional context
A complete patch fixing all 6 issues is prepared as attachment
fix-graphs-docs-code-samples.patch