A cognitive cache for AI agents & RAG
coalent caches the understanding an LLM builds from your sources — keyed by meaning, kept fresh by provenance — so retrieval gets faster and cheaper without ever returning less than plain search.
The freshness-and-reuse layer above retrieval.
Plain RAG re-reads and re-reasons over the same sources on every similar query. coalent sits above your retriever: it reuses the understanding it has already built, keeps it honest with the raw evidence, and invalidates it the moment a source changes.
Caches understanding, not strings
Queries are matched by MEANING, not keywords. A fresh hit serves the cached understanding directly — no retrieval, no LLM call.
Surgical provenance invalidation
When a source changes, only the units whose provenance used it are dirtied. They rebuild lazily on the next read; unchanged content is skipped by content-hash.
Never below the RAG floor
Every unit retains its raw evidence. If a cached understanding doesn't cover a query, coalent escalates to raw retrieval — never less than plain search, never silently wrong.
Bring any retriever
The freshness-and-reuse layer above retrieval — vector DBs, hybrid search, GraphRAG, tools or APIs. Python, pip install coalent, zero required dependencies.
One read method, five moving parts
Everything happens behind a single cache.get() call.
Match by meaning
Embed the query and match the unit whose understanding is closest in meaning — not the query's words.
Serve fresh hits
A hit that is still fresh serves the cached understanding directly: no retrieval and no LLM call.
Coverage check → escalate
If the unit doesn't actually answer the query, escalate to the retained raw — a fresh retrieval, no extra LLM call. This is the RAG floor.
Miss or stale → rebuild
On a miss or a stale unit, retrieve, synthesize the understanding, retain the raw, record provenance, and cache.
Invalidate surgically
source_changed(id) dirties only units whose provenance used that id; they rebuild lazily on the next read.
Install and cache in a few lines.
Pure Python with zero required dependencies. Add the OpenAI extra for real semantic matching, or bring your own provider and retriever.
pip install coalent # core, zero required dependencies pip install "coalent[openai]" # OpenAI provider + embeddings (recommended) # extras: anthropic · qdrant · chroma · pgvector · redis
from coalent import SemanticCache, LLMSynthesizer, OpenAIProvider, OpenAIEmbedder, InMemoryRetriever
retriever = InMemoryRetriever()
retriever.add("confluence:hr", "Leave policy: 21 days of annual leave per year.")
cache = SemanticCache(
retriever,
LLMSynthesizer(OpenAIProvider(), model="gpt-4o-mini"), # builds the understanding
embedder=OpenAIEmbedder(), # match queries by MEANING
)
result = cache.get("how much annual leave?") # the ONE read method
result.context["understanding"] # query-relevant slice (summary + claims + facts)
result.cache_hit # False (cold) -> True on a similar later query
cache.source_changed("confluence:hr", text="Leave policy: now 25 days.") # surgical invalidationExplore coalent.ai
See the full documentation, benchmarks and provider integrations on the coalent site.
