Type Alias: ToolHandler
ts
type ToolHandler = (
args: unknown,
ctx: DispatchContext,
meta: Registry,
) =>
| string
| Uint8Array
| SpooledArtifact
| Media
| Media[]
| Promise<string | Uint8Array | SpooledArtifact | Media | Media[]>;Defined in: src/lib/classes/tool.ts:57
The execution function for a Tool.
Parameters
| Parameter | Type |
|---|---|
args | unknown |
ctx | DispatchContext |
meta | Registry |
Returns
| string | Uint8Array | SpooledArtifact | Media | Media[] | Promise< | string | Uint8Array | SpooledArtifact | 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 viatool.artifactConstructor?.() ?? SpooledArtifactwhen assembling theToolCallrecord.- @nhtio/adk!SpooledArtifact — a pre-built, reader-backed result. Return this when the handler has streamed bytes into storage and wrapped the reader; the consumer passes it through without materialising or re-spooling it. Its concrete class determines the forged
artifact_*query tools. - @nhtio/adk!Media /
Media[]— explicit-modality silo. Bypasses Tool.artifactConstructor — the handler returns the final result shape directly. The LLM battery renders eachMediaas a provider-specific content block.