execute

open suspend override fun execute(context: AIAgentGraphContextBase, input: TInput): TOutput?(source)

Executes the subgraph for the given input within context.

During execution this method:

  • Resolves the effective toolset according to the configured ToolSelectionStrategy and replaces context's LLM context with an updated one, overriding tools, and optionally model, prompt.params and responseProcessor for the duration of the subgraph execution.

  • Emits onSubgraphExecutionStarting, onSubgraphExecutionCompleted and onSubgraphExecutionFailed pipeline events, unless this subgraph is the strategy-level subgraph (which is reported separately).

  • Runs nodes starting from start (or from an enforced ExecutionPoint, if present) and follows edges until finish is reached or execution is interrupted.

  • Restores the original LLM context afterwards, preserving the updated message history.

Return

The output produced by finish, or null if execution was interrupted (for example, due to a requested jump to another node or a checkpoint rollback).

Parameters

context

The graph execution context which includes all necessary resources and metadata for execution.

input

The input data to be processed by the subgraph.