ToolResultBlock
Defined in: src/types/messages.ts:521
Tool result content block.
Implements
Section titled “Implements”JSONSerializable<{toolResult:ToolResultBlockData; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ToolResultBlock(data): ToolResultBlock;Defined in: src/types/messages.ts:549
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { toolUseId: string; status: "success" | "error"; content: ToolResultContent[]; error?: Error; } |
data.toolUseId | string |
data.status | "success" | "error" |
data.content | ToolResultContent[] |
data.error? | Error |
Returns
Section titled “Returns”ToolResultBlock
Properties
Section titled “Properties”readonly type: "toolResultBlock";Defined in: src/types/messages.ts:525
Discriminator for tool result content.
toolUseId
Section titled “toolUseId”readonly toolUseId: string;Defined in: src/types/messages.ts:530
The ID of the tool use that this result corresponds to.
status
Section titled “status”readonly status: "success" | "error";Defined in: src/types/messages.ts:535
Status of the tool execution.
content
Section titled “content”readonly content: ToolResultContent[];Defined in: src/types/messages.ts:540
The content returned by the tool.
error?
Section titled “error?”readonly error?: Error;Defined in: src/types/messages.ts:547
The original error object when status is ‘error’. Available for inspection by hooks, error handlers, and agent loop. Tools must wrap non-Error thrown values into Error objects.
Methods
Section titled “Methods”with()
Section titled “with()”with(overrides): ToolResultBlock;Defined in: src/types/messages.ts:567
Experimental
A shallow copy of this result with the given content in place of its own. The copy keeps this result’s tool use
id, status, and error. Content left out, or set to undefined, keeps this result’s content.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
overrides | { content?: ToolResultContent[]; } | The content of the copy |
overrides.content? | ToolResultContent[] | - |
Returns
Section titled “Returns”ToolResultBlock
The copy
toJSON()
Section titled “toJSON()”toJSON(): { toolResult: ToolResultBlockData;};Defined in: src/types/messages.ts:581
Serializes the ToolResultBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Note: The error field is not serialized (deferred for future implementation).
Returns
Section titled “Returns”{ toolResult: ToolResultBlockData;}| Name | Type | Defined in |
|---|---|---|
toolResult | ToolResultBlockData | src/types/messages.ts:581 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSON
fromJSON()
Section titled “fromJSON()”static fromJSON(data): ToolResultBlock;Defined in: src/types/messages.ts:598
Creates a ToolResultBlock instance from its wrapped data format. Content of a type this version does not recognize becomes an UnknownBlock, so data a newer SDK version saved still loads.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | { toolResult: ToolResultBlockData; } | Wrapped ToolResultBlockData to deserialize |
data.toolResult | ToolResultBlockData | - |
Returns
Section titled “Returns”ToolResultBlock
ToolResultBlock instance