Skip to content
1 min read · 182 words

Type Alias: DispatchExecutorFn

ts
type DispatchExecutorFn = (
  ctx: DispatchContext,
  helpers: DispatchExecutorHelpers,
) => void | Promise<void>;

The user-supplied callback that performs the actual LLM API call within a dispatch.

Parameters

ParameterType
ctxDispatchContext
helpersDispatchExecutorHelpers

Returns

void | Promise<void>

Remarks

Invoked between the input and output middleware pipelines on every iteration. Receives the active @nhtio/adk!DispatchContext and an DispatchExecutorHelpers object that manages per-id streaming state for the dispatch. The executor's responsibilities:

  1. Make the actual LLM API / SDK call (the ADK has no opinion on which provider).
  2. Normalise streaming responses into TurnStreamableContent / TurnToolCallContent shapes and report them via the helpers.
  3. Persist the resulting Message / Thought / ToolCall records via ctx.storeMessage / ctx.storeThought / ctx.storeToolCall once the implementation-specific fields are known.
  4. Decide when the loop is done — typically ctx.ack() after a response with no further tool calls, or ctx.nack(err) on failure. The runner will loop again if neither signal nor abort fires.

Wired into a TurnRunner via TurnRunnerConfig.executorCallback. Invoked once per iteration inside DispatchRunner.dispatch(), between the input and output middleware pipelines.