Building AI Memory Layers with File-Based Vector Storage and Knowledge Graphs
cognee · Tech · 2025 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.4 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Agent memory infrastructure
Cognee needed durable agent memory with graph and vector retrieval while avoiding shared-state collisions across developers, users, tests, demos, and production workspaces.
Constraints:
- Agent memory must combine vector retrieval, graph reasoning, provenance, and time context.
- Developers and tests need isolated memory stores to prevent cross-run contamination.
- The local development model should promote to production without redesign.
- The stack should avoid operational overhead from separate vector services per sandbox.
Architecture
Cognee combines an Extract-Cognify-Load memory pipeline with LanceDB for file-based vector storage, Kuzu for graph storage, and Cogwit as the hosted production service. Each workspace gets its own isolated LanceDB store, while Cognee builds graph-aware and vector-backed memory from files, APIs, and databases.
Diagram confidence: explicit (topology described by the source).
flowchart LR sources[Sources] --> extract-stage[Extract Stage] extract-stage --> cognify-stage[Cognify Stage] cognify-stage --> load-stage[Load Stage] load-stage --> kuzu-graph-store[Kuzu Graph Store] load-stage --> lancedb-vector-store[LanceDB Vector Store] kuzu-graph-store --> cognee-query-engine[Cognee Query Engine] lancedb-vector-store --> cognee-query-engine cognee-query-engine --> memify-pipeline[Memify Pipeline] cognee-query-engine --> agent-or-app[Agent or App] cogwit-hosted-service[Cogwit Hosted Service] --> cognee-query-engine cogwit-hosted-service --> agent-or-app
Components
| Component | Role | Interacts with |
|---|---|---|
Sources |
Files, APIs, and databases ingested into the memory layer. | Extract Stage |
Extract Stage |
Pulls source data into the Cognee pipeline. | Sources, Cognify Stage |
Cognify Stage |
Chunks, embeds, enriches entities and relationships, and adds temporal tagging. | Extract Stage, Load Stage |
Load Stage |
Writes graph structures and vector data into retrieval backends. | Cognify Stage, Kuzu Graph Store, LanceDB Vector Store |
LanceDB Vector Store |
File-based vector store with per-workspace isolation and unified payload/embedding storage. | Load Stage, Cognee Query Engine |
Kuzu Graph Store |
Graph backend for entity and relationship retrieval. | Load Stage, Cognee Query Engine |
Cognee Query Engine |
Serves graph and vector search for agents, apps, notebooks, and local UI. | LanceDB Vector Store, Kuzu Graph Store, Agent or App, Memify Pipeline |
Memify Pipeline |
Post-deployment memory freshness process that cleans stale nodes and improves relevance. | Cognee Query Engine |
Cogwit Hosted Service |
Hosted production path managing Kuzu, LanceDB, PostgreSQL, governance, and autoscaling. | Cognee Query Engine, Agent or App |
Agent or App |
Consumer querying and using the memory layer. | Cognee Query Engine, Cogwit Hosted Service |
Data flow
Sources are extracted, chunked, embedded, enriched into entities and relations, tagged with temporal context, loaded into graph and vector backends, and queried by agents or applications through graph and vector search.
Why this architecture
File-based LanceDB matched Cognee's workspace isolation model, while graph plus vector retrieval made memory more structured than a thin RAG layer.
Models used: embedding models
Scale
- Each developer, user, test, and workspace can receive its own independent store.“isolation model is the way it separates memory stores so that every developer, user, or test instance gets its own fully independent workspace. Instead of sharing a single vector database or graph across contexts, Cognee spins up a dedicated set of backends—most notably a [LanceDB”article, stated
- The same model moves from laptop development to hosted production.
- Production Cogwit manages Kuzu, LanceDB, and PostgreSQL with governance and autoscaling.“which manages Kuzu for graph, LanceDB for vectors, and PostgreSQL for metadata, adding governance and autoscaling”article, stated
Alternatives considered (roads not taken)
Shared vector database or graph across development contexts.
Rejected because: Shared state can cause unpredictable behavior, data corruption, and debugging problems.
Traditional vector databases requiring running servers per sandbox.
Rejected because: That adds service, port, connection, and dependency overhead during development and testing.
Separate document store, vector database, and graph engine glued together.
Rejected because: Cognee and LanceDB reduce orchestration cost by keeping data, vectors, graph, and memory updates aligned.
Patterns
agent-memory (memory)
Cognee builds durable agent memory from graphs, vectors, temporal context, provenance, and post-deployment memory refresh.
rag-retrieval (retrieval)
Applications query both graph structures and vectors for multi-step answers with clearer provenance.
hybrid-search (retrieval)
LanceDB supplies vector and full-text search while Cognee combines that with graph retrieval.
data-quality-loop (memory-maintenance)
Memify refreshes memory after deployment by cleaning stale nodes and reweighting facts instead of full rebuilds.
Tradeoffs
Vector storage model
Chose File-based LanceDB stores per workspace over A shared server-backed vector database.
Rationale: The file model made per-test and per-user isolation cheap and reduced local development overhead.
Memory representation
Chose Knowledge graph plus vector search over Thin RAG over vectors alone.
Rationale: Graph-aware retrieval supports multi-step reasoning, provenance, and time-aware context.
Production migration
Chose Same structures/APIs from local to Cogwit over Redesigning the memory layer for hosted production.
Rationale: The same model can be promoted when governance and scale matter.
Gotchas (what bit them)
Shared memory state makes parallel development unreliable.
Root cause: Multiple developers or tests can mutate the same vector/graph state.
Resolution: Provision independent LanceDB-backed workspaces per developer, user, test, or demo.
Separating payloads from vectors adds synchronization glue.
Root cause: Pipelines must otherwise keep original data and embeddings consistent across stores.
Resolution: Use LanceDB's columnar storage to keep original data and embeddings together.
Index settings become product tradeoffs rather than invisible infrastructure defaults.
Root cause: Recall, latency, and footprint vary by workload.
Resolution: Start with defaults, then profile and adjust indexes and quantization.
Evaluation
Cognee validates memory quality through isolated local sandboxes, graph/vector query inspection, index profiling, and graph-aware evaluation including HotPotQA-style multi-hop reasoning.
Metrics: Retrieval accuracy · Multi-hop correctness · CI friction · Demo reliability · Recall, latency, and footprint
Outcomes
- Cognee gained per-workspace vector isolation for tests, users, demos, and development.
- The graph-plus-vector memory layer improved retrieval quality on multi-hop reasoning tasks.
- The same local setup can move to Cogwit production without redesign.
The source describes one isolated store per test/user/workspace and promotion from laptop workflows to hosted production with governance and autoscaling.