Anvia
Tools

Tool Sets

Group and reuse tools across agents.

Use ToolSet when you want to group tools, inspect definitions, call tools directly, or share a collection across agents.

Create a Tool Set

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

const supportTools = ToolSet.fromTools([
  lookupOrder,
  searchDocs,
  createTicket,
]);

Register on an Agent

Agents accept arrays of tools.

const agent = new AgentBuilder("support", model)
  .tools(supportTools.values())
  .defaultMaxTurns(3)
  .build();

Use ToolSet as the reusable collection, then pass its values into AgentBuilder.

Call a Tool Directly

This is useful for tests and internal tooling.

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

ToolSet.call(...) parses the JSON string, validates input, runs the tool, validates output, and returns the serialized result.

Combine Tool Sets

const supportTools = ToolSet.fromTools([lookupOrder]);
const billingTools = ToolSet.fromTools([lookupInvoice]);

supportTools.addTools(billingTools);

When two tools have the same name, the later tool replaces the earlier one.

Inspect Definitions

const definitions = await supportTools.getToolDefinitions();

Definitions are the provider-facing tool schemas sent to completion models.