hal_register_tools: Register Multiple Tools on the Active Session

View source: R/tool-builder.R

hal_register_toolsR Documentation

Register Multiple Tools on the Active Session

Description

Registers a list of tools on the active hal() session so the model can call them. Each element may be an ellmer::ToolDef (e.g. from daisy::daisy_tools()) or a plain hal tool list with name / description / fun / parameters. Unlike hal_register_tool(), which builds a tool from a bare function's formals, this passes each element through the chat's tool normalizer, so pre-built ToolDefs keep their declared argument schema.

Usage

hal_register_tools(tools)

Arguments

tools

A list of tool definitions (ellmer::ToolDef objects or hal tool lists).

Value

Invisibly, the number of tools registered.

See Also

hal_register_tool(), hal_register_tool_specs()

Examples

## Not run: 
tools <- list(
  hal_tool(function(x, y) x + y, "add",
    description = "Add two numbers",
    types = list(x = "number", y = "number")
  ),
  hal_tool(function(path) readLines(path), "read_file",
    description = "Read a text file"
  )
)
hal_register_tools(tools)

## End(Not run)

hal documentation built on Oct. 6, 2026, 5:07 p.m.