ToolResponse

public abstract class ToolResponse extends JsonSerializable

The output from a server-side `ToolCall` execution.

This message contains the results of a tool invocation that was initiated by a `ToolCall` from the model. The client should pass this `ToolResponse` back to the API in a subsequent turn within a `Content` message, along with the corresponding `ToolCall`.

Constructors

Link copied to clipboard
public void ToolResponse()

Types

Link copied to clipboard
public abstract class Builder
Builder for ToolResponse.

Properties

Link copied to clipboard
public final static String MAX_READ_LENGTH_PROPERTY
System property to override the default max JSON string length (20MB) in read constraints.

Functions

Link copied to clipboard
public static ToolResponse.Builder builder()
Instantiates a builder for ToolResponse.
Link copied to clipboard
public static ToolResponse fromJson(String jsonString)
Deserializes a JSON string to a ToolResponse object.
Link copied to clipboard
@InternalApi()
public static T fromJsonNode<T extends JsonSerializable>(JsonNode jsonNode, Class<T> clazz)
Deserializes a JsonNode to an object of the given type.
Link copied to clipboard
@InternalApi()
public static T fromJsonString<T extends JsonSerializable>(String jsonString, Class<T> clazz)
Deserializes a Json string to an object of the given type.
Link copied to clipboard
public abstract Optional<String> id()
The identifier of the tool call this response is for.
Link copied to clipboard
public static ObjectMapper objectMapper()
Link copied to clipboard
public abstract Optional<Map<String, Object>> response()
The tool response.
Link copied to clipboard
public static void setMaxReadLength(int maxReadLength)
Overrides the default maximum JSON string length (20MB) for the JSON parser.
Link copied to clipboard
public static JsonNode stringToJsonNode(String string)
Converts a Json string to a JsonNode.
Link copied to clipboard
public abstract ToolResponse.Builder toBuilder()
Creates a builder with the same values as this instance.
Link copied to clipboard
public String toJson()
Serializes the instance to a Json string.
Link copied to clipboard
public static JsonNode toJsonNode(Object object)
Serializes an object to a JsonNode.
Link copied to clipboard
public static String toJsonString(Object object)
Serializes an object to a Json string.
Link copied to clipboard
public abstract Optional<ToolType> toolType()
The type of tool that was called, matching the tool_type in the corresponding ToolCall.