claude/types/tool

Types

An opaque collection of tools, keyed by name.

pub opaque type Registry

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 is_empty(reg: Registry) -> Bool

Check if the registry is empty.

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())

pub fn registry() -> Registry

Create an empty tool registry.

pub fn to_json(reg: Registry) -> json.Json

Encode all tools as a JSON array for the API request.

pub fn unregister(reg: Registry, name: String) -> Registry

Remove a tool by name.

Search Document