Skip to main content
A tool is a function the model can call during a run. You describe it as a class implementing ITool: a name, a description, an optional input schema, and a handler. The agent loop exposes the tool to the model, validates the arguments the model supplies against your schema, runs your handler, and feeds the result back into the conversation.

Defining a tool

Implement ITool<P, R>, where P is the validated input and R is the handler’s return type. Register the class with decorator.tool():
Add it to any agent’s getTools, or pass it per request:

The ITool contract

A clear getDescription and a precise getInputSchema are what make a tool reliable, because the model decides whether and how to call the tool entirely from those two. Describe the input fields in the schema and the tool’s purpose in the description.

Validated input

When getInputSchema is present, the agent loop validates the model’s arguments against it before your handler runs. Inside handler, the input already matches the schema, so there are no manual checks to write. The schema is an ArkType assertion built with Assert from @talosjs/validation:
Omit getInputSchema for a tool that takes no arguments.

Call hooks

A tool can observe or gate its own invocation with two optional hooks. When any tool on a run declares either hook, the agent loop bridges them onto the run automatically.

onBeforeCall

Runs before the handler. Return a decision to allow, modify, or block the call, which is useful for permission checks or argument rewriting:

onAfterCall

Runs after the handler returns, for logging, metrics, or auditing:
Both hooks receive the run’s ChatMiddlewareContext as their first argument, so they can read ctx.context, the runtime context passed to the call.

Built-in tools

The package ships ready-made tools for web search, Wikipedia, PubMed, and Linear. See Built-in Tools for the full catalog and the keys they need.