public final class ToolResultPart

  1. Object
  2. MessagePart
  3. ToolResultPart
The result of a tool invocation, sent back to the model so it can continue reasoning. Pairs with the originating ToolCall via the toolCallId. The carrying ChatMessage should use Role.TOOL. Result content sent back to a model after executing a requested tool call. The result is JSON text so providers receive the original structured value.

Constructors

public ToolResultPart(String toolCallId, String resultJson)resultJson is the literal JSON string the tool produced.

Methods

public String getToolCallId()
public String getResultJson()

Inherited methods

Constructor details

ToolResultPart

public ToolResultPart(String toolCallId, String resultJson)
resultJson is the literal JSON string the tool produced. If the tool result isn’t valid JSON, wrap it like "{\"text\":\"...\"}" – the providers expect JSON-shaped values. Creates a tool result part.

Parameters

toolCallId String
id of the ToolCall being answered
resultJson String
JSON value returned by the application tool

Method details

getToolCallId

public String getToolCallId()

Returns

provider tool-call id this result answers

getResultJson

public String getResultJson()

Returns

application result encoded as JSON