Skip to content

AgentTool

Interface for tools the LLM can call during the agent loop. Re-exported from @mariozechner/pi-agent-core.

Source: @durable-streams/darix-runtime (re-export)

ts
interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> {
  name: string
  label: string
  description: string
  parameters: TParameters
  execute: (
    toolCallId: string,
    params: Static<TParameters>,
    signal?: AbortSignal,
    onUpdate?: AgentToolUpdateCallback<TDetails>
  ) => Promise<AgentToolResult<TDetails>>
}

Fields

FieldTypeRequiredDescription
namestringYesUnique tool name used in LLM function calling.
labelstringYesHuman-readable label for display.
descriptionstringYesDescription sent to the LLM to explain when and how to use the tool.
parametersTSchemaYesTypeBox JSON Schema defining the tool's parameters.
execute(toolCallId, params, signal?, onUpdate?) => Promise<AgentToolResult>YesFunction called when the LLM invokes the tool.

Parameters are defined using TypeBox (@sinclair/typebox). The schema is used for LLM function calling and argument validation.

AgentToolResult

ts
interface AgentToolResult<T = any> {
  content: (TextContent | ImageContent)[]
  details: T
}
FieldTypeDescription
content(TextContent | ImageContent)[]Content returned to the LLM. Typically { type: 'text', text: string }.
detailsTArbitrary metadata. Must be provided (use {} if no details).

WARNING

Every tool must return a details property. Omitting it causes a type error.