pub enum ContentBlock {
Text {
text: String,
extras: Extras,
},
Thinking {
thinking: String,
signature: String,
extras: Extras,
},
ToolUse {
id: String,
name: String,
input: Value,
extras: Extras,
},
ToolResult {
tool_use_id: String,
content: Value,
is_error: bool,
extras: Extras,
},
ServerToolUse {
id: String,
name: String,
input: Value,
extras: Extras,
},
ServerToolResult {
tool_use_id: String,
content: Value,
extras: Extras,
},
Document {
source: Value,
extras: Extras,
},
Image {
source: Value,
extras: Extras,
},
QueuedCommand {
prompt: Value,
command_mode: Option<String>,
source_uuid: Option<String>,
extras: Extras,
},
Unknown {
type_str: String,
raw: Value,
},
}Expand description
A single block inside an assistant turn’s content array or a user
message’s tool-result envelope.
Variants§
Text
Plain text from the assistant.
Fields
Thinking
Extended-thinking reasoning block. Present when the model was run in thinking mode.
Fields
ToolUse
The model wants to invoke a tool.
Fields
ToolResult
A tool’s output, sent back to the model in a user turn.
Fields
ServerToolUse
Server-side tool invocation the API executed on the model’s behalf
(e.g. advisor, web_search, web_fetch). Surfaces alongside
regular ToolUse blocks but the caller never returns a result -
the server supplies one in a matching ContentBlock::ServerToolResult.
ServerToolUseBlock.
name is a discriminator: typed as the Literal set
{"advisor", "web_search", "web_fetch", "code_execution", "bash_code_execution", "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25"}. forge-sdk
keeps it as String so new server tools don’t require an SDK
bump to deserialise.
Fields
ServerToolResult
Result block for a server-side tool call (wire type
advisor_tool_result). Same wire shape as ToolResult but
the content dict is opaque - branch on content["type"]
to tell which concrete server-tool result schema applies (e.g.
advisor_result vs. advisor_redacted_result).
Fields
tool_use_id: StringThe id from the corresponding ContentBlock::ServerToolUse block.
Document
Document attachment (PDF, etc.) inlined into a user turn. The
Anthropic API supports these directly - when the user attaches
a file to a Claude Code conversation, the CLI emits
{"type":"document","source":{"type":"base64", "media_type":"<mime>","data":"<base64>"}} (or "type":"url" /
"type":"text" for the alternate source variants).
source stays a Value rather than a typed struct because
Anthropic’s source schema branches on source.type
(base64 / url / text / content) and each variant
carries different fields - keeping it as a JSON object lets
new source types decode without an SDK bump.
Fields
Image
Image attachment (JPEG / PNG / GIF / WEBP) inlined into a user
turn. Same shape as ContentBlock::Document but with
"type":"image" on the wire. Surfaced when a user pastes or
attaches an image in a Claude Code conversation.
Fields
QueuedCommand
User input that was typed while a previous turn was in flight
and got “queued” by the CLI. Claude Code packages these as
queued_command-type content blocks on the next outbound
user-message envelope going to the model, so the model sees
them as additional context.
Wire shape (from the CLI binary’s gO6 function):
{"type": "queued_command",
"prompt": "<text or content-block list>",
"commandMode": "prompt" | "bash",
"source_uuid": "<optional>",
...}Forge surfaces this so resumed sessions render the queued inputs as user bubbles in the chat. Without it, a session that had mid-turn queued inputs would replay missing those user messages.
Fields
prompt: ValueThe queued user text (or content-block array - kept as
Value so list-of-blocks variants pass through cleanly).
command_mode: Option<String>Mode the input was submitted in. Typically "prompt";
"bash" for !-prefixed shell commands.
Unknown
Forward-compat fallback for content block types forge-sdk
doesn’t model explicitly. Callers can branch on type_str +
inspect raw - the decoder never errors on an unrecognised
block. Mirrors the top-level
the SDK’s DecodedLine::Unknown
fallback pattern.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§impl Serialize for ContentBlock
Wire-shape type discriminator used by the custom (de)serialise
impls. The discriminator mirrors the original #[serde(tag="type")]
layout but lets us fall through to ContentBlock::Unknown for
anything we don’t recognise.
impl Serialize for ContentBlock
Wire-shape type discriminator used by the custom (de)serialise
impls. The discriminator mirrors the original #[serde(tag="type")]
layout but lets us fall through to ContentBlock::Unknown for
anything we don’t recognise.