Documentation / guides
Tool definitions
Declare callable tools with a name, description, and raw JSON schema.
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
- Source:
inference/client.go - Tests:
inference/client_test.gocovers raw schema preservation and feature conflicts.
Related: ToolUseBlock, Tool choice, Structured output with tools.