Skip to main content

Module tool

Module tool 

Source
Expand description

Tool trait and utilities for defining agent tools.

Tools are the primary way agents interact with the world. Each tool represents a specific capability that an agent can invoke.

§OpenAI API Alignment

This module aligns with OpenAI’s Function Calling API:

  • ToolDefinition serializes to {"type": "function", "function": {...}} format
  • Supports strict mode for Structured Outputs
  • Compatible with both Chat Completions and Responses APIs

Structs§

AlwaysDenyHandler
Confirmation handler that always denies execution.
AutoApproveHandler
Default confirmation handler that auto-approves all requests.
ToolCallResult
Result of a tool call execution.
ToolConfirmationRequest
Request for human confirmation before tool execution.
ToolDefinition
Definition of a tool for LLM function calling.

Enums§

ToolConfirmationResponse
Response to a tool confirmation request.
ToolError
Error type for tool execution failures.
ToolExecutionPolicy
Execution policy for a tool.

Traits§

ConfirmationHandler
Handler for tool execution confirmation requests.
DynTool
Object-safe version of the Tool trait for dynamic dispatch.
Tool
The core trait for all tools that agents can use.

Type Aliases§

BoxedConfirmationHandler
A boxed confirmation handler for dynamic dispatch.
BoxedTool
A boxed dynamic tool that can be used in collections.
SharedConfirmationHandler
A shared confirmation handler for use across cloneable contexts.
ToolResult
A type alias for Result<T, ToolError>.