DocsRuntimellm-providersConvertToolsToAnthropicFormat
Package: @hexos/runtime

Converts Hexos tool definitions to Anthropic’s tool format.

Transforms each tool’s name, description, and Zod input schema into the format required by the Anthropic Messages API. The schema conversion function is injected to handle Zod-to-JSON Schema transformation.

This conversion is performed once per agent stream initialization, before calling the Anthropic API.

function convertToolsToAnthropicFormat(tools: ToolDefinition[], toJsonSchema: (schema: unknown) => Record<string, unknown>): Anthropic.Tool[]

Parameters

tools

toJsonSchema

(schema: unknown) => Record