Skip to main content

Module 05: Message Types

Understanding the message and content block type hierarchy.

What You’ll Learn

  • The four message types: User, Assistant, System, Result
  • Content block types inside Assistant messages
  • Pattern matching with sealed interfaces
  • Extracting text and tool use information

Message Type Hierarchy

Content Block Types

Inside AssistantMessage.content():

Pattern Matching with Switch

ResultMessage Fields

AssistantMessage Convenience Methods

Message toString() Methods

All message types have useful toString() implementations:

Source Code

View on GitHub

Running the Example

Next Module

Module 06: CLI Options - Learn about fine-grained configuration of Claude’s behavior.