Class References
Function References
- text
- textOptions
- combineStrategies
- convertMessagesToModelMessages
- convertZodToJsonSchema
- createReplayStream
- embedding
- generateMessageId
- maxIterations
- messages
- modelMessageToUIMessage
- modelMessagesToUIMessages
- normalizeToUIMessage
- parsePartialJSON
- summarize
- toServerSentEventsStream
- toServerSentEventsResponse
- toolDefinition
- uiMessageToModelMessages
- realtimeToken
- untilFinishReason
Interface References
- AIAdapter
- AIAdapterConfig
- AgentLoopState
- AudioPart
- AudioVisualization
- BaseStreamChunk
- TextCompletionChunk
- TextOptions
- ChunkRecording
- ChunkStrategy
- ClientTool
- ContentPartSource
- ContentStreamChunk
- DefaultMessageMetadataByModality
- DocumentPart
- DoneStreamChunk
- EmbeddingOptions
- EmbeddingResult
- ErrorStreamChunk
- ImagePart
- InternalToolCallState
- JSONParser
- ModelMessage
- ProcessorResult
- ProcessorState
- RealtimeAdapter
- RealtimeClientOptions
- RealtimeConnection
- RealtimeMessage
- RealtimeSessionConfig
- RealtimeToken
- RealtimeTokenAdapter
- RealtimeTokenOptions
- ResponseFormat
- ServerTool
- StreamProcessorEvents
- StreamProcessorHandlers
- StreamProcessorOptions
- SummarizationOptions
- SummarizationResult
- TextPart
- ThinkingPart
- ThinkingStreamChunk
- Tool
- ToolCall
- ToolCallPart
- ToolCallStreamChunk
- ToolConfig
- ToolDefinition
- ToolDefinitionConfig
- ToolDefinitionInstance
- ToolInputAvailableStreamChunk
- ToolResultPart
- ToolResultStreamChunk
- UIMessage
- VideoPart
Type Alias References
- AgentLoopStrategy
- AnyClientTool
- TextStreamOptionsForModel
- TextStreamOptionsUnion
- ConstrainedContent
- ConstrainedModelMessage
- ContentPart
- ContentPartForModalities
- ExtractModalitiesForModel
- ExtractModelsFromAdapter
- InferToolInput
- InferToolName
- InferToolOutput
- MessagePart
- RealtimeEvent
- RealtimeMessagePart
- RealtimeMode
- RealtimeStatus
- ModalitiesArrayToUnion
- Modality
- StreamChunk
- ToolCallState
- ToolResultState
Variable References
mergeAgentTools
Call Signature#
function mergeAgentTools<TServerTools>(serverTools, clientTools): TServerTools;Defined in: packages/ai/src/utilities/chat-params.ts:349
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 chat-client.ts onToolCall), giving the "after server execution the client also handles" semantic for free.
- Client-only tools (name not in serverTools) become no-execute entries: the runtime's existing ClientToolRequest path handles them — server emits a tool-call request, client executes via its registered handler, client posts back the result.
Typing:
- Empty clientTools preserves the server tuple (closed name union).
- Non-empty clientTools returns a widened array that honestly includes client stubs, so the merged array does not claim a closed server-only name union.
Type Parameters#
TServerTools#
TServerTools extends readonly AnyTool[]
Parameters#
serverTools#
TServerTools
The server's tool array (e.g. from [myToolDef.server(...)]). Pass directly to chat({ tools }).
clientTools#
readonly []
The tools array received from chatParamsFromRequest(...) / chatParamsFromRequestBody(...).
Returns#
TServerTools
A merged array suitable for chat({ tools }).
Call Signature#
function mergeAgentTools<TServerTools>(serverTools, clientTools): MergedAgentTools<TServerTools>;Defined in: packages/ai/src/utilities/chat-params.ts:352
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 chat-client.ts onToolCall), giving the "after server execution the client also handles" semantic for free.
- Client-only tools (name not in serverTools) become no-execute entries: the runtime's existing ClientToolRequest path handles them — server emits a tool-call request, client executes via its registered handler, client posts back the result.
Typing:
- Empty clientTools preserves the server tuple (closed name union).
- Non-empty clientTools returns a widened array that honestly includes client stubs, so the merged array does not claim a closed server-only name union.
Type Parameters#
TServerTools#
TServerTools extends readonly AnyTool[]
Parameters#
serverTools#
TServerTools
The server's tool array (e.g. from [myToolDef.server(...)]). Pass directly to chat({ tools }).
clientTools#
readonly object[]
The tools array received from chatParamsFromRequest(...) / chatParamsFromRequestBody(...).
Returns#
MergedAgentTools<TServerTools>
A merged array suitable for chat({ tools }).