CreateMessageResult

data class CreateMessageResult(val role: Role, val content: List<SamplingMessageContent>, val model: String, val stopReason: StopReason? = null, val meta: JsonObject? = null) : ClientResult(source)

The client's response to a CreateMessageRequest from the server.

The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.

Constructors

Link copied to clipboard
constructor(role: Role, content: List<SamplingMessageContent>, model: String, stopReason: StopReason? = null, meta: JsonObject? = null)
constructor(role: Role, content: SamplingMessageContent, model: String, stopReason: StopReason? = null, meta: JsonObject? = null)

Convenience constructor for a single-block response. Wraps content in a singleton list so call sites can write CreateMessageResult(Role.Assistant, TextContent("ok"), "model-name") without the explicit listOf(...).

Properties

Link copied to clipboard

The generated content blocks; at least one block is required.

Link copied to clipboard
@SerialName(value = "_meta")
open override val meta: JsonObject?

Optional metadata for this response.

Link copied to clipboard

The name of the model that generated the message (e.g., "claude-3-opus-20240229").

Link copied to clipboard
val role: Role

The role of the message sender. Typically Role.Assistant for LLM-generated responses.

Link copied to clipboard

The reason why sampling stopped, if known. Common values: StopReason.EndTurn, StopReason.StopSequence, StopReason.MaxTokens, StopReason.ToolUse.