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

    Class NodeContext

    The execution context for a workflow node — the TypeScript analogue of google/adk-python agents/context.py::Context (the workflow flavour).

    It exposes ctx.runNode(...) for programmatic child execution, ctx.state for delta-aware session state, ctx.emit(...) to stream an event, and the mutable output/route/interruptIds a node sets while running.

    Constructors

    Properties

    abortSignal?: AbortSignal

    Abort signal for the current node run, set by the engine while the node is executing under a deadline or an external cancellation signal — i.e. when the node declares a timeout, when the invocation itself can be aborted, or when it runs inside a Workflow (whose signal fires if a sibling fails). Cooperative node bodies can observe ctx.abortSignal to wind down their own in-flight work (e.g. pass it to a model/tool call); the engine also stops consuming the node's events once it fires, so nothing is pushed past cancellation. A fired timeout surfaces as a NodeTimeoutError; an external abort stops the node without raising.

    actions: EventActions
    attemptCount: number = 1

    The current attempt number (1-based) for the running node (see retry).

    channel: AsyncQueue<Event>
    interruptIds: string[] = []

    Interrupt ids the node is currently blocked on (HITL).

    invocationContext: InvocationContext
    isolationScope?: string
    nodePath: string
    output: unknown = undefined

    The structured output produced by the node during its run.

    outputDelegated: boolean = false

    Whether this node handed its output to a child run with useAsOutput.

    The child already emitted that value as its own result, so an event from this node repeating it would put the same text in the stream twice. The node still reports the output — only the duplicate event is suppressed.

    outputForAncestors: readonly string[] = []

    Node paths whose output this node's output also becomes: its parent's if the parent ran it with useAsOutput, plus whatever the parent was standing in for. Stamped onto every output event as nodeInfo.outputFor, so a resumed run can tell that an ancestor already has a result.

    reportedError?: { errorCode?: string; errorMessage?: string }

    The failure a node reported by emitting an error event rather than by throwing. Read back at the end of the attempt; cleared per attempt.

    resumeInputs: Record<string, unknown>

    The route key(s) emitted by the node, if any (array = multi-route).

    runId: string

    The dynamic-node scheduler for this subtree. When set, ctx.runNode() routes through it (dedup/resume/fresh); otherwise it runs the child directly. Propagated to child contexts by the node runner; a nested Workflow overrides it with its own scheduler.

    stateSchema?: SchemaLike

    The state schema in force for this node, inherited by its children unless they declare their own.

    Accessors

    Methods

    • The invocation context to run a nested agent against.

      The single place where "what a node sees" is translated into "what an agent sees", so an agent run as a node (BaseAgent.runImpl) and one run directly go through the same seam.

      It hands back the node's own invocation context unchanged, and that is the intended behaviour rather than a placeholder.

      adk-python's counterpart (agents/context.py get_invocation_context) is documented as returning "a copy with the proxy session", which reads as though the agent is handed a different view of state. It is not: that Context.session returns self._invocation_context.session, so the copy substitutes the same object, and Context._state is built directly over session.state. A Python agent run as a node reads session state exactly as a TypeScript one does.

      The other thing that copy carries — the isolation scope — is already applied by the time this runs: the node runner builds the child invocation context with the node's scope, so it is present on the object returned.

      That leaves the node's own state, which is this node's pending delta over session.state — the same thing an agent reads, so the two cannot disagree. The agent-node cases in core/test/workflow/state_consistency_test.ts pin that.

      Returns InvocationContext

    • Runs a child node programmatically, streaming its events through the same channel and resolving to the child's result — a full NodeContext for a node that actually ran, or a bare NodeResult for one that was fast-forwarded from cached output on resume. Either way the caller can read output, route, branch, and interruptIds; only a NodeContext offers live behaviour (emit, state, nested runNode).

      When a dynamic-node scheduler is set (inside a Workflow subtree), the call routes through it for dedup/resume; otherwise the child runs directly.

      Takes anything an edge takes — an agent, a tool, a plain function, or an already-built node — and wraps it the same way the graph does, so ctx.runNode(myAgent, input) works without node(myAgent). Wrap it yourself when you need the options node() carries, such as a schema or a name that differs from the value's own.

      Parameters

      Returns Promise<NodeContext | NodeResult>