SamplingMessage

A single message in a sampling conversation. role is "user" or "assistant"; content reuses the SDK's Content block (text/image/audio).

Constructors

this
this(string role, Content c, Json meta)

Construct a single-block message (back-compat convenience).

this
this(string role, Content[] blocks, Json meta)

Construct a multi-block message (e.g. parallel tool_use/tool_result).

Members

Functions

content
Content content()

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

content
void content(Content c)

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

Variables

contentBlocks
Content[] contentBlocks;

All content blocks of the message. The spec models a sampling message's content as a single block OR an array of blocks (SamplingMessageContentBlock | SamplingMessageContentBlock[], schema.ts). A tool-loop follow-up request carries multiple blocks: an assistant message with several tool_use blocks and a user message with several tool_result blocks. This field holds every block so none is dropped. For the common single-block message, use the content accessor.

meta
Json meta;

optional message-level _meta object (schema.ts: SamplingMessage.meta)

role
string role;

"user" or "assistant"