action
Declare an async function tool the model can call; its resolved return value becomes the tool result shipped back to the model.
import { action } from '@threadplane/chat';Declaration · overload 1
export declare function action<S extends StandardSchemaV1, R>(description: string, schema: S, handler: (args: StandardSchemaInferOutput<S>, context: FunctionToolHandlerContext) => R | Promise<R>, options?: ClientToolExecutionOptions): FunctionToolDef<S, R>;Type parameters
R
Parameters
description· requiredstringNatural-language description the model sees.
schema· requiredSStandard Schema (e.g. a Zod object) for the arguments; the handler's argument type is inferred from it.
handler· required(args: StandardSchemaInferOutput<S>, context: FunctionToolHandlerContext) => R | Promise<R>Runs in the browser when the model calls the tool. The second argument carries an
AbortSignal; its return typeRis carried on the resulting FunctionToolDef.options· optionalClientToolExecutionOptionsExecution policy options, including
idempotent: trueto skip durable pre-execution claims when a guard is configured.
Returns
FunctionToolDef<S, R>A FunctionToolDef for inclusion in tools.
Examples
const move = action('Move a stop', z.object({ fromDay: z.number() }), (a) => a.fromDay);
const registry = tools({ move_stop: move });