Anvia
Tools

Tool Registry

Store mutable local tools for agents and tests.

ToolRegistry is the local runtime store for tools. Most apps only need .tool(...) and .tools(...) on AgentBuilder, but a registry is useful when tools need to be added, removed, or shared after an agent is created.

Create a Registry

import { ToolRegistry } from "@anvia/core";

const registry = new ToolRegistry()
  .addTool(lookupOrder)
  .addTool(searchDocs);

Pass the registry into an agent.

const agent = new AgentBuilder("support", model)
  .toolRegistry(registry)
  .defaultMaxTurns(3)
  .build();

Add or Remove Tools

registry.addTool(createTicket);
registry.removeTool("search_docs");

The agent reads the registry when building each model request, so later prompts see the updated tool list.

Append a Tool Set

registry.addToolSet(ToolSet.fromTools([lookupInvoice, refundOrder]));

Use this when features, tenants, or plugins contribute tools at runtime.

Call a Tool Manually

const result = await registry.callTool(
  "lookup_order",
  JSON.stringify({ orderId: "A-100" }),
);

Manual calls are useful in tests and admin workflows. Agent runs call the same registry internally.

Static Tool Definitions

ToolRegistry.getToolDefinitions(...) returns the tool definitions that will be advertised to the model.

const definitions = await registry.getToolDefinitions("Where is order A-100?");

Most tools are static. If you need prompt-dependent tool definitions, implement the lower-level Tool interface directly.