Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

createToolRegistry.md

46 lines1.0 KB

1---
2id: createToolRegistry
3title: createToolRegistry
4---
5​
6# Function: createToolRegistry()
7​
8```ts
9function createToolRegistry(initialTools): ToolRegistry;
10```
11​
12Defined in: [packages/typescript/ai/src/tool-registry.ts:78](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/tool-registry.ts#L78)
13​
14Create a mutable tool registry for dynamic tool scenarios.
15​
16Tools can be added and removed during chat execution, and the
17changes will be reflected in subsequent agent loop iterations.
18​
19## Parameters
20​
21### initialTools
22​
23[`Tool`](../interfaces/Tool.md)\<[`SchemaInput`](../type-aliases/SchemaInput.md), [`SchemaInput`](../type-aliases/SchemaInput.md), `string`\>[] = `[]`
24​
25Optional initial set of tools
26​
27## Returns
28​
29[`ToolRegistry`](../interfaces/ToolRegistry.md)
30​
31A mutable ToolRegistry
32​
33## Example
34​
35```typescript
36const registry = createToolRegistry([toolA, toolB])
37​
38const stream = chat({
39 adapter,
40 messages,
41 toolRegistry: registry,
42})
43​
44// Later, during tool execution:
45registry.add(newTool) // Immediately available to LLM
46```