Skip to content

Dynamic tools ​

Dynamic tools let Anvia search a large tool catalog and send only the most relevant tool definitions to the model for each turn.

Explore dynamic tools ​

PageLearn how to
Tool setsGroup and execute concrete tool implementations.
Tool indexBuild a searchable catalog and attach it to an agent.
Embedding textImprove selection with accurate capability language.
Static and dynamicKeep essential tools visible while retrieving the long tail.
SafetyFilter exposure and enforce authorization at execution.
ChecklistVerify relevance, permissions, and catalog freshness.

Why retrieve tools ​

Static tools are included in every model turn. That is the right default for a small, stable set, but a large catalog increases prompt size and makes tool choice less focused.

Dynamic selection adds a retrieval step:

text
Current prompt
    ↓
Search embedded tool definitions
    ↓
Apply metadata filter and threshold
    ↓
Send selected definitions to the model
    ↓
Execute the chosen tool from the backing ToolSet

The model sees only selected definitions. The application still owns every concrete tool implementation.

Build a dynamic catalog ​

ts
import { AgentBuilder } from '@anvia/core'
import { createToolIndex } from '@anvia/core/tool'
import { vectorFilter } from '@anvia/core/vector-store'

const toolIndex = await createToolIndex(
  embeddingModel,
  allSupportTools,
  {
    metadata(tool) {
      return {
        productArea: tool.name.startsWith('billing_')
          ? 'billing'
          : 'support',
      }
    },
  },
)

const agent = new AgentBuilder('billing-support', model)
  .dynamicTools(toolIndex, {
    topK: 6,
    threshold: 0.72,
    filter: vectorFilter.eq('productArea', 'billing'),
  })
  .build()

Anvia searches again before every turn. Tool results can change the current runtime prompt, so a later turn may receive a different set of definitions.

Use it for scale, not authorization ​

Dynamic retrieval narrows the model-facing action surface. It does not prove that the user may execute a selected tool. Every handler must still validate input, enforce user and tenant permissions, protect side effects, and record sensitive actions.

Built for Anvia.