BaseMessage is the abstract base class for all LangChain message types, and modeling messages as objects instead of raw strings allows them to carry rich, structured metadata (tool calls, IDs, roles) that is essential for multi-turn conversations, tool use, and state management across providers [citation:1][citation:6].
BaseMessage is the foundational class that defines the common properties and methods for all specific message types like HumanMessage and AIMessage. Modeling messages as objects rather than raw strings provides a number of critical benefits: it enables the attachment of standardized roles (type), unique identifiers (id), LLM-provider-specific metadata (response_metadata), and support for rich content blocks beyond plain text [citation:1][citation:6]. This structured approach is essential for building robust, provider-agnostic applications.
The object-oriented approach is what enables LangGraph's powerful state management features. For example, by giving each message a unique id, LangGraph can perform RemoveMessage operations to surgically delete specific messages from history, rather than having to rebuild the entire history array [citation:10]. Additionally, the BaseMessage contract allows for the streaming of partial message chunks (AIMessageChunk), which can be merged back into a complete message [citation:2][citation:6].