Open Agent Loops
API Reference

toToolSpec

@open-agent-loops/core


function toToolSpec(tool): ToolSpec;

Defined in: tools/tools.ts:71

Convert a tool to the spec shape the model client advertises.

Parameters

ParameterTypeDescription
toolToolThe tool to advertise to the model.

Returns

ToolSpec

A ToolSpec carrying the tool's name, description, and JSON Schema parameters.

Remarks

The tool's Zod schema is converted to JSON Schema (via z.toJSONSchema), which is the form function-calling models expect on the wire.

See

Example

import { toToolSpec } from "@open-agent-loops/core/tools/tools";

const spec = toToolSpec(addTool);
// spec.parameters is a JSON Schema object describing { a, b }
await modelClient.complete({ messages, tools: [spec] });

On this page