GeezerVison is showing adk.dev — ParallelWorker | ADK for TypeScript: API Reference - v2.5.0
A node that runs a wrapped node once per item of a list input, preserving
order, bounded by maxParallelWorkers, and stopping on the first error.
Ported from google/adk-python workflow/_parallel_worker.py. A non-list
input is treated as a single-element list. Each item runs via
ctx.runNode(inner, item, {useSubBranch: true}); the node's output is the
ordered list of the children's outputs.
The wrapped value is anything an edge accepts — an agent, a tool, a plain
function, or an already-built node — and is built the same way, so
new ParallelWorker(myAgent) works without node(myAgent). It is built when
the worker is constructed, not per item, so every item runs the one inner
node — which is also where the worker's own name comes from.
Notes:
- retry/timeout live on the inner node.
retryConfig/timeout passed to
buildNode apply to the wrapped node (per item); the ParallelWorker itself
carries neither, so the two levels don't compose. Wrapping the value
yourself — new ParallelWorker(node(myAgent, {timeout: 5})) — is how those
options are set.
- All-or-nothing. If any item throws, the first error is rethrown and the
already-computed sibling outputs are discarded. Make individual items
failure-tolerant if partial results matter.
- An item that interrupts pauses the whole worker. It has no output to
contribute, so the worker stops claiming items, emits no list, and raises
the child's interrupt ids as its own. Once they are answered the worker
re-runs from the top (
rerunOnResume), and items that already completed
are fast-forwarded by their run id rather than executed again.
- Cancellation stops scheduling only. On abort/timeout the loop stops
claiming new items, but items already in flight run to completion —
ctx.runNode has no way to forward a signal into a child run.
Constructors
Properties
Readonly[BASE_NODE_SIGNATURE_SYMBOL]
"[BASE_NODE_SIGNATURE_SYMBOL]": true
Brand identifying this object as a BaseNode (see isBaseNode).
Readonly[PARALLEL_WORKER_SIGNATURE_SYMBOL]
"[PARALLEL_WORKER_SIGNATURE_SYMBOL]": true
Readonlydescription
description: string
Optional ReadonlyinputSchema
Optional ReadonlyisolationScope
isolationScope?: string | true
Optional ReadonlymaxParallelWorkers
maxParallelWorkers?: number
Readonlyname
name: string
Optional ReadonlyoutputSchema
Optional ReadonlypreparedRetryConfig
The retry config with its exception filter normalized once, up front (see
prepareRetryConfig). Used by the node runner so the retry hot path
never re-normalizes or throws on a malformed config mid-retry.
ReadonlyrerunOnResume
rerunOnResume: boolean
Optional ReadonlyretryConfig
Optional ReadonlystateSchema
Optional Readonlytimeout
timeout?: number
ReadonlywaitForOutput
waitForOutput: boolean
Accessors
Methods
run
-
Runs the node, normalizing every yielded item into an Event. This
is what the engine (and ctx.runNode()) consumes. Validates the input
against inputSchema once, up front (skipping genai Content, which nodes
coerce themselves).
Returns AsyncGenerator<Event, void, void>
ProtectedrunImpl
-
runImpl(ctx: NodeContext, input: unknown): AsyncGenerator<unknown, void, void>
Core execution contract. Subclasses yield one of:
- an Event (emitted as-is),
- a raw value (boxed into an event whose
output is that value),
null/undefined (skipped).
Returns AsyncGenerator<unknown, void, void>
ProtectedtoEvent
-
Normalizes a single yielded item into an Event (or null to skip).
Subclasses may override for richer coercion (e.g. FunctionNode).
Returns Event | null
ProtectedvalidateInput
-
validateInput(input: unknown): unknown
Validates node input against inputSchema (Content passes through). Only
enforced for Zod schemas; a genai Schema is left unvalidated (see
parseWithSchema).
Returns unknown
ProtectedvalidateOutput
-
validateOutput(output: unknown): unknown
Validates node output against outputSchema (Content passes through). Only
enforced for Zod schemas; a genai Schema is left unvalidated (see
parseWithSchema).
Returns unknown
Constructors
Properties
Accessors
Methods
|