Represent completed tool execution
Build or validate tool messages passed to AI SDK Core model operations.
AI Tools · Type Alias
ToolResultPart represents one completed tool call within a tool message. It links the result to the call and tool, stores JSON-serializable output, and optionally carries provider-specific metadata.
ToolResultPart is one item in a tool message's content array. It identifies the completed call, names the tool, carries its JSON-serializable output, and can optionally preserve provider-specific options for downstream handling.
export interface ToolResultPart {
type: 'tool-result';
toolCallId: string;
toolName: string;
output: ToolResultOutput;
providerOptions?: ProviderOptions;
}| Name | Type | Description |
|---|---|---|
type | 'tool-result' | Discriminator identifying this part as a tool result. |
toolCallId | string | ID of the associated tool call. |
toolName | string | Name of the tool that generated the result. |
output | ToolResultOutput | JSON-serializable result of the tool call. |
providerOptions | ProviderOptions | undefined | Optional provider-specific metadata. |
A ToolResultPart object representing one tool-call result in a tool message.
import type { ToolResultPart } from 'ai';
const result: ToolResultPart = {
type: 'tool-result',
toolCallId: 'call_123',
toolName: 'weather',
output: { temperatureC: 21, condition: 'clear' },
};
console.log(result.output);Creates a typed tool-result message part with the call identity, tool name, and JSON-serializable output.
Build or validate tool messages passed to AI SDK Core model operations.
Correlate returned data with the exact invocation in a multi-call conversation.
Preserve provider-specific metadata while keeping the result structure standardized.
ToolResultPart represents the result of a tool call inside a tool message. Its required fields identify the part as a tool result, associate it with the call, name the tool, and provide the output.
Follow-up: How is it placed in a model message? It is an element of ToolContent, and ToolContent is an array of ToolResultPart values.
The discriminator is type: 'tool-result'. toolCallId links the result to the originating call, while toolName records which tool produced it.
Follow-up: Why retain both identifiers? A call ID provides correlation, while the tool name supplies semantic identity for consumers handling the message.
output contains the tool's JSON-serializable result. providerOptions may carry provider-specific metadata that the SDK passes through to the provider.
Follow-up: When should providerOptions be used? Use it only when a provider feature requires extra metadata; keep the actual tool result in output.
ToolModelMessageToolContentModelMessageProviderOptionsToolResultOutput