CreateMessageResult

Result of a sampling/createMessage request, returned by the client. Parse the client's reply with fromJson; build one (client side) with the constructor-style fields and toJson. stopReason is the raw wire string (which may be a known StopReason or a provider-specific value); use stopReasonEnum for the typed view.

Members

Functions

content
void content(Content c)

Set the result to a single content block (back-compat convenience).

content
Content content()

The first (or only) content block, for the common single-block reply. Returns an empty text block when there are no blocks. For tool-use replies (which carry several tool_use blocks) iterate contentBlocks.

stopReasonEnum
Nullable!StopReason stopReasonEnum()

The typed view of stopReason, or null when it is empty or a provider-specific value not in the StopReason enum.

Static functions

text
CreateMessageResult text(string model, string text, string stopReason, string role)

Build a single-text-block reply, the common onSampling case: an assistant message whose content is one Content.makeText(text) block. Parity with Content.makeText / ElicitResult.accept — saves a handler from assembling the struct by hand. stopReason defaults to "endTurn" and role to "assistant".

Variables

contentBlocks
Content[] contentBlocks;

All content blocks of the reply. The spec models content as a single block OR an array of blocks (`SamplingMessageContentBlock | SamplingMessageContentBlock[]); a tool-use reply (stopReason:"toolUse"`) returns an array of tool_use blocks. This field holds every block so no tool_use id/name/input is dropped. For the common single-block reply, use the content accessor.

meta
Json meta;

optional message-level _meta object (CreateMessageResult extends SamplingMessage)

model
string model;

the model identifier the client actually used

role
string role;

"user" or "assistant" (typically "assistant")

stopReason
string stopReason;

raw stop-reason wire string (may be empty)