ToolMessage

@Serializable
@SerialName(value = "tool")
class ToolMessage(val content: String, val toolCallId: String) : ChatMessage

Tool-role message — the result of executing a ToolCall produced by the model.

Echo toolCallId from the matching ToolCall so the model can correlate the result with its original call.

Example:

val toolResult = ToolMessage(
content = Json.encodeToString(weatherResponse),
toolCallId = toolCall.id,
)

Constructors

Link copied to clipboard
constructor(content: String, toolCallId: String)

Properties

Link copied to clipboard
open override val content: String

Result of the tool execution, typically JSON-encoded.

Link copied to clipboard

Identifier of the ToolCall this message responds to.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String