ExAthena.Tools (ExAthena v0.5.0)

Copy Markdown View Source

Resolves tool modules into the shape the provider + loop expect.

Consumers supply tools in one of two ways:

  1. At config time:

    config :ex_athena, tools: [MyApp.ToolA, MyApp.ToolB]
  2. Per-call:

    ExAthena.Loop.run(messages, tools: [MyApp.ToolA, ExAthena.Tools.Read])

Per-call wins; the configured list is the default when no tools are passed.

Summary

Functions

List the builtin tool modules.

Build the prompt-friendly list used by ExAthena.ToolCalls.augment_system_prompt/3 when we fall back to the TextTagged protocol.

Build the provider-facing tool schema list — the same shape Ollama / OpenAI-compatible providers send on the wire.

Find the tool module that handles a call by name.

Resolve the tools to use for a call. Accepts

Validate that every module in modules implements the Tool behaviour.

Functions

builtins()

@spec builtins() :: [module()]

List the builtin tool modules.

describe_for_prompt(modules)

@spec describe_for_prompt([module()]) :: [map()]

Build the prompt-friendly list used by ExAthena.ToolCalls.augment_system_prompt/3 when we fall back to the TextTagged protocol.

describe_for_provider(modules)

@spec describe_for_provider([module()]) :: [map()]

Build the provider-facing tool schema list — the same shape Ollama / OpenAI-compatible providers send on the wire.

find(modules, name)

@spec find([module()], String.t()) :: module() | nil

Find the tool module that handles a call by name.

resolve(opts)

@spec resolve(keyword()) :: [module()]

Resolve the tools to use for a call. Accepts:

  • a list of modules
  • :all — every builtin
  • nil — falls back to config :ex_athena, tools: ... or :all

validate!(modules)

@spec validate!([module()]) :: :ok

Validate that every module in modules implements the Tool behaviour.