claude/types/tool
Types
A typed tool definition. Carries its own schema, decoder, and execute fn.
pub type Tool(params) {
Tool(
name: String,
description: String,
params_schema: glon.JsonSchema(params),
execute: fn(params) -> Result(String, String),
)
}
Constructors
-
Tool( name: String, description: String, params_schema: glon.JsonSchema(params), execute: fn(params) -> Result(String, String), )
How the model should choose which tool to use.
pub type ToolChoice {
Auto(disable_parallel: Bool)
Any(disable_parallel: Bool)
SpecificTool(name: String, disable_parallel: Bool)
NoTools
}
Constructors
-
Auto(disable_parallel: Bool) -
Any(disable_parallel: Bool) -
SpecificTool(name: String, disable_parallel: Bool) -
NoTools
Values
pub fn dispatch(
reg: Registry,
name: String,
input: String,
) -> Result(String, String)
Dispatch a tool call by name. Used by the tool runner.
The input string is parsed from JSON on each call. This is a known trade-off: tool input is stored as a JSON string for conversation history serialization, requiring a parse-serialize-parse cycle when the API response is decoded and then dispatched. A future optimization could pass the raw Dynamic value directly to avoid the redundant JSON round-trip.
pub fn register(reg: Registry, tool: Tool(params)) -> Registry
Register a typed tool. Erases the type parameter internally.
Pipeable: registry() |> register(weather_tool()) |> register(search_tool())