ExAgent.Tool (ExAgent v0.1.0)

Copy Markdown View Source

A tool the model may call.

ExAgent.Tool bundles everything: the serialisable ToolDefinition (name, description, JSON-Schema parameters) and the actual callable that runs when the model invokes it. Use definition/1 to project the shape a provider sends to the model.

Tools are normally built via the deftool macro (see ExAgent.Tools), which derives the JSON-Schema from the function's @spec. They can also be built by hand with new/1.

Summary

Functions

Serialisable projection sent to the model: name + description + params.

Build a tool by hand.

Types

kind()

@type kind() :: :function | :output | :external | :unapproved

t()

@type t() :: %ExAgent.Tool{
  call: (ExAgent.RunContext.t(), map() -> term()) | (map() -> term()) | nil,
  description: String.t() | nil,
  kind: kind(),
  max_retries: non_neg_integer(),
  name: String.t(),
  parameters_json_schema: map(),
  takes_ctx: boolean()
}

Functions

definition(tool)

@spec definition(t()) :: map()

Serialisable projection sent to the model: name + description + params.

new(opts)

@spec new(keyword()) :: t()

Build a tool by hand.