CockroachDBChatMessageHistory stores chat conversation history in CockroachDB’s distributed SQL database.
The code lives in the integration package: langchain-cockroachdb.
Overview
CockroachDBChatMessageHistory provides:- Distributed storage: Chat history automatically replicated across nodes
- Strong consistency: SERIALIZABLE transactions prevent message ordering issues
- High availability: Automatic failover with no data loss
- Session isolation: Each conversation has a unique session ID
- PostgreSQL compatibility: Easy migration from PostgreSQL-based systems
Setup
Install
Connection string
Initialization
Create the message history table
Initialize for a session
Create a chat history instance for a specific conversation:Usage
Add messages
Add multiple messages at once
Retrieve messages
Get all messages for the session:Clear conversation history
Delete all messages for the session:Sync interface
Use the synchronous API:API reference
For detailed documentation:Additional resources
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

