Design a multi-tenant message store by using LangGraph's checkpointing with a thread_id that incorporates tenant, user, and session identifiers, and optionally implement a custom BaseCheckpointSaver that adds tenant isolation at the storage layer.
LangGraph's checkpointing already provides isolation through the thread_id key in the config. To achieve multi-tenancy, you construct the thread_id to include tenant and user IDs, e.g., tenant-{tenant_id}:user-{user_id}:session-{session_id}. This ensures that checkpoints for different tenants/users are stored under different keys and never mix. For additional security, you can subclass the checkpoint saver (e.g., PostgresSaver) and add a tenant_id column to the database table, then override the get and put methods to filter by tenant. This prevents accidental cross-tenant access at the storage level.