ADK for TypeScript: API Reference
    Preparing search index...

    Class ParallelWorker

    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.

    Hierarchy (View Summary)

    Constructors

    Properties

    "[BASE_NODE_SIGNATURE_SYMBOL]": true

    Brand identifying this object as a BaseNode (see isBaseNode).

    description: string
    inputSchema?: SchemaLike
    isolationScope?: string | true
    maxParallelWorkers?: number
    name: string
    outputSchema?: SchemaLike
    preparedRetryConfig?: PreparedRetryConfig

    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.

    rerunOnResume: boolean
    retryConfig?: RetryConfig
    stateSchema?: SchemaLike
    timeout?: number
    waitForOutput: boolean

    Accessors

    • get requiresAllPredecessors(): boolean

      Whether this node must wait for ALL of its predecessors to trigger before it runs (fan-in barrier). Overridden by JoinNode.

      Returns boolean

    Methods

    • 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).

      Parameters

      Returns AsyncGenerator<Event, void, void>

    • Validates node input against inputSchema (Content passes through). Only enforced for Zod schemas; a genai Schema is left unvalidated (see parseWithSchema).

      Parameters

      • input: unknown

      Returns unknown

    • Validates node output against outputSchema (Content passes through). Only enforced for Zod schemas; a genai Schema is left unvalidated (see parseWithSchema).

      Parameters

      • output: unknown

      Returns unknown