Memory for AI Agents in 5 lines of code – build dynamic, modular ECL (Extract-Cognify-Load) pipelines that combine vector + graph storage to replace classic RAG systems.
https://github.com/topoteretes/cogneeYour AI agents forget everything between conversations. You're rebuilding context from scratch every time, losing valuable insights, and watching your context windows explode with redundant information. Traditional RAG helps, but it's still just sophisticated keyword matching that misses the rich relationships in your data.
Cognee changes this. It's a memory system that gives your AI agents persistent, interconnected knowledge – combining vector similarity with graph relationships to understand not just what information exists, but how it all connects together.
Most developers default to vector databases for AI memory. You embed documents, store them, and retrieve similar chunks when needed. It works for basic Q&A, but falls apart when you need:
Cognee solves this with its ECL (Extract-Cognify-Load) pipeline that builds knowledge graphs alongside vector indexes, creating memory that actually understands relationships.
5-line integration that immediately gives your agents persistent memory:
import cognee
# Add information
await cognee.add("Our Q4 revenue target is $2M, with $500K from new enterprise deals")
await cognee.cognify() # Build the knowledge graph
# Query with understanding
results = await cognee.search("What are our enterprise revenue goals?")
# Returns contextually relevant information, not just keyword matches
Hybrid retrieval that combines vector similarity with graph traversal. When you ask about "enterprise goals," it doesn't just find documents containing those words – it follows the relationships to connect revenue targets, deal types, and time periods.
Modular storage backends – start with SQLite for development, scale to Neo4j for production knowledge graphs with millions of relationships.
Multi-session customer support agents that remember previous interactions, understand customer history, and can connect issues across multiple touchpoints. Instead of asking customers to repeat their setup every time, your agent builds cumulative understanding.
Research assistants that maintain context across multiple documents and can answer complex questions like "How do the findings in paper X relate to the methodology criticism in paper Y?" The graph structure lets it trace connections that pure vector search would miss.
Code analysis agents that understand your codebase relationships – not just finding similar functions, but understanding dependencies, call patterns, and architectural decisions over time.
The included MCP server wrapper exposes Cognee's memory capabilities as standardized tools:
AddMemory
: Store new information with automatic relationship extractionSearchMemory
: Query with hybrid vector+graph retrievalSummarizeMemory
: Generate contextual summaries to fit context windowsGraphRAG
: Perform multi-hop reasoning across your knowledge graphDeploy it as a microservice and connect it to any AI system that supports MCP. Your agents get persistent, intelligent memory without changing their core architecture.
Install and configure in under 5 minutes:
pip install cognee[neo4j] # Include graph database support
export OPENAI_API_KEY="your-key"
export NEO4J_URI="bolt://localhost:7687" # Or use SQLite for local dev
The MCP server runs with:
python examples/server.py --host 0.0.0.0 --port 8080
Now your agents can POST
to /memory/add
to store information and /memory/query
to retrieve with full relationship understanding.
Traditional RAG treats your data as isolated chunks. Cognee builds a knowledge graph where every piece of information connects to related concepts, creating memory that mirrors how humans actually think and remember.
When you ask about "Q4 targets," it doesn't just return documents containing those words. It follows the graph to understand that Q4 connects to revenue goals, which connect to enterprise deals, which connect to specific customer segments – giving you comprehensive, contextual answers.
This isn't theoretical. The research paper shows significant improvements in multi-hop question answering and reasoning tasks compared to traditional RAG approaches.
Ready to give your AI agents memory that actually works? The 5.8k stars and active community suggest you're not alone in needing this capability.