CL SDK separates business logic from persistence entirely. Every agent and pipeline depends on storage interfaces — not concrete implementations. You wire in whatever database fits your infrastructure: Postgres with pgvector, Pinecone, Convex, Supabase, or any other store that can implement the interface contracts. CL SDK ships a SQLite reference implementation for local development and testing.
DocumentStore
DocumentStore persists fully extracted InsuranceDocument records — policies and quotes — and supports querying by carrier, insured name, policy number, and quote number.
The query agent reads from DocumentStore to resolve document references in user messages. The extractor writes to it after a successful extraction.
MemoryStore
MemoryStore handles two things: chunked document content for vector search, and conversation history for cross-session continuity. Both are optional but unlock the query agent’s most useful capabilities.
addChunks accepts DocumentChunk[] objects produced by your chunking pipeline. search returns the top-k most relevant chunks for an embedding query. addTurn and getHistory manage per-conversation message history, while searchHistory supports semantic search across past turns.
SourceStore
SourceStore extends SourceRetriever and is the persistence layer for your source grounding evidence. It stores both raw SourceSpan objects and the larger SourceChunk retrieval windows derived from them.
Because SourceStore implements SourceRetriever, you can pass any SourceStore instance directly to agents and pipelines via the sourceRetriever config option.
SQLite Reference Implementation
The createSqliteStore factory returns a single store object that satisfies DocumentStore, MemoryStore, and SourceStore. It uses SQLite with a local vector similarity index for development and testing.
SQLite is a reference implementation for development and testing only. For production, implement the interfaces against a database that supports concurrent access and durable vector search — Postgres with pgvector, Pinecone, Convex, or a similar store.
Application and PCE Stores
Two additional interfaces support stateful multi-step workflows.
ApplicationStore persists application pipeline state across multiple email or chat rounds. It stores the current batch of open questions, the insured’s answers so far, and any context writes produced by the pipeline.
BackfillProvider allows the application pipeline to pre-populate answers from prior submissions, existing policies, or external CRM data. Implement this interface to prevent asking the same questions on renewal.
Both interfaces are optional — the application pipeline degrades gracefully without them, treating every session as a fresh start.
Data Flow
The diagram below shows how data moves through CL SDK’s storage layer across a typical extraction and query session.
Implementing Your Own Store
Any class that satisfies the interface signatures works. Here is a minimal DocumentStore backed by a Postgres table:
Start with MemorySourceStore and MemoryDocumentStore to get extraction and querying working end-to-end. Once your pipeline is stable, swap in your production stores by replacing the config option — no other code changes required.