Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Tool definitions

Declare callable tools with a name, description, and raw JSON schema.

developer

Tool describes one callable function exposed to the model. The inference package carries the schema as raw JSON; the tool implementation owns semantic validation and execution.

API surface

type Tool struct {
	Name        string
	Description string
	Schema      json.RawMessage
}
tool := inference.Tool{
	Name: "weather",
	Description: "Look up the current weather for a city.",
	Schema: json.RawMessage(`{
		"type":"object",
		"properties":{"city":{"type":"string"}},
		"required":["city"],
		"additionalProperties":false
	}`),
}
request := inference.Request{Tools: []inference.Tool{tool}}

Name is the uniqueness key. When structured output is also requested, _looprig_final_output is reserved and duplicate tool names are rejected. A nil or malformed tool schema is preserved as input to the codec; ValidateRequestFeatures validates the structured output schema, not ordinary tool schemas.

The Harness tool calls and results guide shows the consumer lifecycle: expose a definition, inspect returned ToolUseBlock values, execute the selected tool, and append a correlated result.

Proof

Related: ToolUseBlock, Tool choice, Structured output with tools.

← back to documentation