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

mergeAgentTools

Function: mergeAgentTools()

ts
function mergeAgentTools<TContext>(serverTools, clientTools): Tool<SchemaInput, SchemaInput, string, TContext>[];
function mergeAgentTools<TContext>(serverTools, clientTools): Tool<SchemaInput, SchemaInput, string, TContext>[];

Defined in: packages/ai/src/utilities/chat-params.ts:187

Merge a server-side tool array with the AG-UI client-declared tools received in the request body.

Rules:

  • Server tools win on name collision. The client's declaration is ignored if the server already has a tool with that name. The client's UI-side handler still fires when the streamed tool-result event comes through (see ), giving the "after server execution the client also handles" semantic for free.
  • Client-only tools (name not in ) become no-execute entries: the runtime's existing path handles them — server emits a tool-call request, client executes via its registered handler, client posts back the result.

Type Parameters

TContext

=

Parameters

serverTools

readonly <, , , >[]

The server's tool array (e.g. from ). Pass directly to .

clientTools

readonly []

The array received from / .

Returns

<, , , >[]

A merged array suitable for .