You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(workflow): Use SingleAgentReactNode for leaf single_turn agents in new Workflow
In the new _workflow_class.py Workflow, leaf single_turn LlmAgents now
run through SingleAgentReactNode instead of _SingleLlmAgent. This
enables proper event deduplication via _output_delegated — only the
LlmCallNode content event appears in the stream, not a duplicate
wrapper output event.
The old _workflow.py Workflow retains the original _SingleLlmAgent
path. Runtime detection uses event_queue presence on InvocationContext
to distinguish the two paths.
Also updates the use_as_output sample to use an LLM agent as the
delegated child node, and rewrites wrapper tests per adk-style
guidelines covering both old and new workflow paths.
Change-Id: I96aea3f12fe432d0449268eb75580c900fd047d7
Copy file name to clipboardExpand all lines: contributing/workflow_samples/use_as_output/README.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,11 @@ This sample demonstrates how to use `ctx.run_node(node, use_as_output=True)` to
6
6
7
7
When `use_as_output=True` is set, the child node's output replaces the parent's output. The parent's own output event is suppressed to avoid duplication, and the child's output flows downstream through the graph as if the parent produced it.
8
8
9
+
The child node can be any node type — this sample uses a single_turn LLM agent (`summarizer`) as the delegated child.
10
+
9
11
## Sample Inputs
10
12
11
-
- Any text input (e.g. `hello world`)
13
+
- Any text input (e.g. `The quick brown fox jumped over the lazy dog near the riverbank on a warm summer afternoon`)
12
14
13
15
## Graph
14
16
@@ -17,33 +19,38 @@ When `use_as_output=True` is set, the child node's output replaces the parent's
17
19
|
18
20
v
19
21
[orchestrate]
20
-
| (delegates output to [transform] via ctx.run_node)
22
+
| (delegates output to [summarizer] via ctx.run_node)
21
23
v
22
24
[finalize]
23
25
```
24
26
25
27
## How To
26
28
27
-
1.**Mark the orchestrator as rerun_on_resume**: The parent node that calls `ctx.run_node` must use `@node(rerun_on_resume=True)`.
29
+
1.**Define the child node**: The child can be a function or an LLM agent. Its output becomes the parent's output and flows to downstream nodes.
30
+
31
+
```python
32
+
from google.adk import Agent
33
+
34
+
summarizer = Agent(
35
+
name='summarizer',
36
+
model='gemini-2.5-flash',
37
+
instruction='Summarize the following text in one sentence.',
38
+
)
39
+
```
40
+
41
+
2.**Mark the orchestrator as rerun_on_resume**: The parent node that calls `ctx.run_node` must use `@node(rerun_on_resume=True)`.
0 commit comments