Skip to content
1 min read · 143 words

Type Alias: ToolHandler

ts
type ToolHandler = (
  args: unknown,
  ctx: DispatchContext,
  meta: Registry,
) =>
  | string
  | Uint8Array
  | Media
  | Media[]
  | Promise<string | Uint8Array | Media | Media[]>;

The execution function for a Tool.

Parameters

ParameterType
argsunknown
ctxDispatchContext
metaRegistry

Returns

| string | Uint8Array | Media | Media[] | Promise< | string | Uint8Array | Media | Media[]>

Remarks

Receives the raw arguments passed to the executor, the active @nhtio/adk!DispatchContext, and the tool's metadata registry.

Return shapes:

  • string / Uint8Array — opaque serialised output. The ADK does not persist the bytes itself; the consumer's executor middleware is responsible for storing them and wrapping them via tool.artifactConstructor?.() ?? SpooledArtifact when assembling the ToolCall record.
  • @nhtio/adk!Media / Media[] — explicit-modality silo. Bypasses Tool.artifactConstructor — the handler returns the final result shape directly. The LLM battery renders each Media as a provider-specific content block.