Overview
Content blocks represent different types of content within messages. They are used in bothUserMessage and AssistantMessage content.
TextBlock
Represents plain text content.The text content.
Example
ThinkingBlock
Represents Claude’s internal reasoning (extended thinking).The thinking content showing Claude’s reasoning process.
Cryptographic signature verifying the thinking content.
Example
Thinking blocks are only present when extended thinking is enabled via the
thinking option in ClaudeAgentOptions.ToolUseBlock
Represents Claude’s intent to use a tool.Unique identifier for this tool use (e.g.,
"toolu_01ABC123").Name of the tool being invoked (e.g.,
"Bash", "Read", "Write").Tool input parameters as a dictionary.
Example
Common Tool Input Schemas
ToolResultBlock
Represents the result of a tool execution.ID of the tool use this result corresponds to (matches
ToolUseBlock.id).Tool output content. Can be:
- A string for simple text output
- A list of content blocks for structured output
Noneif the tool had no output
Whether the tool execution resulted in an error.
Example
Pattern Matching Example
Python 3.10+ pattern matching makes it easy to handle different content block types:Type Guards
For older Python versions or more explicit type checking:Related Types
- Message Types - Message containers that hold content blocks
- ClaudeAgentOptions - Configuration including tool and thinking settings