Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

ToolResultMessage

Return tool output to the model with stable call correlation.

developer

ToolResultMessage is the tool-authored turn that answers one assistant tool call. It embeds the normal role and blocks, then adds correlation and error metadata.

API surface

type ToolResultMessage struct {
	Message
	ToolUseID string
	IsError   bool
}
result := &content.ToolResultMessage{
	Message: content.Message{
		Role: content.RoleTool,
		Blocks: []content.Block{&content.TextBlock{Text: "72 degrees"}},
	},
	ToolUseID: "call-1",
	IsError:   false,
}

ToolUseID must match the originating ToolUseBlock.ID. IsError is omitted from JSON when false and encoded as "is_error":true when true. The custom message codec is important: relying on the promoted Message.MarshalJSON would lose ToolUseID.

Failure results

Set IsError when the tool execution failed, and put a useful, non-secret explanation in the blocks. The inference layer does not execute tools or validate the result payload; those policies belong to the caller.

Proof

Related: ToolResultBlock, Tool choice.

← back to documentation