GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — ParallelWorker | ADK for TypeScript: API Reference - v2.5.0

  • ParallelWorker

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)

  • BaseNode
    • ParallelWorker
  • Defined in core/src/workflow/nodes/parallel_worker.ts:67

Constructors

constructor

  • new ParallelWorker(
        inner: RunnableNode,
        config?: ParallelWorkerConfig,
    ): ParallelWorker

    Parameters

    • inner: RunnableNode
    • config: ParallelWorkerConfig = {}

    Returns ParallelWorker

    Overrides BaseNode.constructor

    • Defined in core/src/workflow/nodes/parallel_worker.ts:72

Properties

Readonly[BASE_NODE_SIGNATURE_SYMBOL]

"[BASE_NODE_SIGNATURE_SYMBOL]": true

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

Inherited from BaseNode.[BASE_NODE_SIGNATURE_SYMBOL]

  • Defined in core/src/workflow/base_node.ts:88

Readonly[PARALLEL_WORKER_SIGNATURE_SYMBOL]

"[PARALLEL_WORKER_SIGNATURE_SYMBOL]": true
  • Defined in core/src/workflow/nodes/parallel_worker.ts:68

Readonlydescription

description: string

Inherited from BaseNode.description

  • Defined in core/src/workflow/base_node.ts:91

Readonlyinner

inner: BaseNode
  • Defined in core/src/workflow/nodes/parallel_worker.ts:70

Optional ReadonlyinputSchema

inputSchema?: SchemaLike

Inherited from BaseNode.inputSchema

  • Defined in core/src/workflow/base_node.ts:102

Optional ReadonlyisolationScope

isolationScope?: string | true

Inherited from BaseNode.isolationScope

  • Defined in core/src/workflow/base_node.ts:105

Optional ReadonlymaxParallelWorkers

maxParallelWorkers?: number
  • Defined in core/src/workflow/nodes/parallel_worker.ts:69

Readonlyname

name: string

Inherited from BaseNode.name

  • Defined in core/src/workflow/base_node.ts:90

Optional ReadonlyoutputSchema

outputSchema?: SchemaLike

Inherited from BaseNode.outputSchema

  • Defined in core/src/workflow/base_node.ts:103

Optional ReadonlypreparedRetryConfig

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.

Inherited from BaseNode.preparedRetryConfig

  • Defined in core/src/workflow/base_node.ts:100

ReadonlyrerunOnResume

rerunOnResume: boolean

Inherited from BaseNode.rerunOnResume

  • Defined in core/src/workflow/base_node.ts:92

Optional ReadonlyretryConfig

retryConfig?: RetryConfig

Inherited from BaseNode.retryConfig

  • Defined in core/src/workflow/base_node.ts:94

Optional ReadonlystateSchema

stateSchema?: SchemaLike

Inherited from BaseNode.stateSchema

  • Defined in core/src/workflow/base_node.ts:104

Optional Readonlytimeout

timeout?: number

Inherited from BaseNode.timeout

  • Defined in core/src/workflow/base_node.ts:101

ReadonlywaitForOutput

waitForOutput: boolean

Inherited from BaseNode.waitForOutput

  • Defined in core/src/workflow/base_node.ts:93

Accessors

requiresAllPredecessors

  • 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

    Inherited from BaseNode.requiresAllPredecessors

    • Defined in core/src/workflow/base_node.ts:134

Methods

run

  • run(ctx: NodeContext, input: unknown): AsyncGenerator<Event, void, void>

    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

    • ctx: NodeContext
    • input: unknown

    Returns AsyncGenerator<Event, void, void>

    Inherited from BaseNode.run

    • Defined in core/src/workflow/base_node.ts:155

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

    Parameters

    • ctx: NodeContext
    • input: unknown

    Returns AsyncGenerator<unknown, void, void>

    Overrides BaseNode.runImpl

    • Defined in core/src/workflow/nodes/parallel_worker.ts:85

ProtectedtoEvent

  • toEvent(ctx: NodeContext, data: unknown): Event | null

    Normalizes a single yielded item into an Event (or null to skip). Subclasses may override for richer coercion (e.g. FunctionNode).

    Parameters

    • ctx: NodeContext
    • data: unknown

    Returns Event | null

    Inherited from BaseNode.toEvent

    • Defined in core/src/workflow/base_node.ts:217

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

    Parameters

    • input: unknown

    Returns unknown

    Inherited from BaseNode.validateInput

    • Defined in core/src/workflow/base_node.ts:178

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

    Parameters

    • output: unknown

    Returns unknown

    Inherited from BaseNode.validateOutput

    • Defined in core/src/workflow/base_node.ts:198
Constructors
constructor
Properties
[BASE_NODE_SIGNATURE_SYMBOL][PARALLEL_WORKER_SIGNATURE_SYMBOL]descriptioninnerinputSchemaisolationScopemaxParallelWorkersnameoutputSchemapreparedRetryConfigrerunOnResumeretryConfigstateSchematimeoutwaitForOutput
Accessors
requiresAllPredecessors
Methods
runrunImpltoEventvalidateInputvalidateOutput
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.