Skip to content

ToolResultBlock

Defined in: src/types/messages.ts:521

Tool result content block.

new ToolResultBlock(data): ToolResultBlock;

Defined in: src/types/messages.ts:549

ParameterType
data{ toolUseId: string; status: "success" | "error"; content: ToolResultContent[]; error?: Error; }
data.toolUseIdstring
data.status"success" | "error"
data.contentToolResultContent[]
data.error?Error

ToolResultBlock

readonly type: "toolResultBlock";

Defined in: src/types/messages.ts:525

Discriminator for tool result content.


readonly toolUseId: string;

Defined in: src/types/messages.ts:530

The ID of the tool use that this result corresponds to.


readonly status: "success" | "error";

Defined in: src/types/messages.ts:535

Status of the tool execution.


readonly content: ToolResultContent[];

Defined in: src/types/messages.ts:540

The content returned by the tool.


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.

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.

ParameterTypeDescription
overrides{ content?: ToolResultContent[]; }The content of the copy
overrides.content?ToolResultContent[]-

ToolResultBlock

The copy


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).

{
toolResult: ToolResultBlockData;
}
NameTypeDefined in
toolResultToolResultBlockDatasrc/types/messages.ts:581

JSONSerializable.toJSON


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.

ParameterTypeDescription
data{ toolResult: ToolResultBlockData; }Wrapped ToolResultBlockData to deserialize
data.toolResultToolResultBlockData-

ToolResultBlock

ToolResultBlock instance