Docs
CodeRabbit
Cloudflare
Railway
Clerk
SerpAPI
Netlify
OpenRouter
WorkOS
AG Grid
Sentry
Unkey
Prisma
Electric
CodeRabbit
Cloudflare
Railway
Clerk
SerpAPI
Netlify
OpenRouter
WorkOS
AG Grid
Sentry
Unkey
Prisma
Electric
Class References
Function References
Interface References
Type Alias References
Variable References

createToolRegistry

Function: createToolRegistry()

ts
function createToolRegistry<TTool>(initialTools): ToolRegistry<TTool>;
function createToolRegistry<TTool>(initialTools): ToolRegistry<TTool>;

Defined in: packages/ai/src/tool-registry.ts:78

Create a mutable tool registry for dynamic tool scenarios.

Tools can be added and removed during chat execution, and the changes will be reflected in subsequent agent loop iterations.

Type Parameters

TTool

TTool extends AnyTool = AnyTool

Parameters

initialTools

TTool[] = []

Optional initial set of tools

Returns

ToolRegistry<TTool>

A mutable ToolRegistry

Example

typescript
const registry = createToolRegistry([toolA, toolB])

const stream = chat({
  adapter,
  messages,
  toolRegistry: registry,
})

// Later, during tool execution:
registry.add(newTool)  // Immediately available to LLM
const registry = createToolRegistry([toolA, toolB])

const stream = chat({
  adapter,
  messages,
  toolRegistry: registry,
})

// Later, during tool execution:
registry.add(newTool)  // Immediately available to LLM