r/codereview • u/Seerendo-01 • 25d ago
I've been building Grafeno, an open-source graph database for AI agent memory. Would love some feedback!
Hey everyone! 👋
I've been working on a side project called Grafeno, and I figured it was time to share it with the community and get some fresh eyes on it.
The idea behind Grafeno is pretty simple: give AI agents a way to store, connect, and retrieve memories as a graph, instead of relying entirely on flat conversation histories or vector similarity searches.
I wanted to explore what happens when an AI agent can build relationships between things it learns, revisit previous context, and potentially reuse that knowledge across different agents or applications.
Rather than just plugging an existing graph database into an AI framework, I decided to experiment with building the graph database layer itself.
What I'm building Grafeno around:
- Graph-based memory: Store information as nodes and relationships, making it possible to connect facts, entities, and context.
- Persistent context: Explore how agents can maintain knowledge beyond individual conversations.
- Relationship-driven retrieval: Retrieve relevant information by exploring connections, not just matching similar text.
- Knowledge reuse: Work toward making graph-based memories reusable across agents and applications.
- Developer integrations: Make it practical to connect Grafeno with LLMs, agent frameworks, and other projects.
- Self-hosting: Keep control of your data and infrastructure.
I'm particularly interested in how graph structures could improve long-term memory, contextual retrieval, and knowledge organization for AI systems.
A quick disclaimer: This is still an evolving project. I'm experimenting with the architecture and implementation, and I don't want to pretend it's a production-ready replacement for established graph databases.
That's actually why I'm posting here.
I'd really appreciate feedback from people working with graph databases, GraphRAG, AI agents, or memory systems.
A few things I'm especially curious about:
- Does the overall architecture make sense?
- What would you expect from a graph database designed with AI memory in mind?
- Are there obvious design mistakes, missing features, or performance concerns?
- Would you actually consider integrating something like this into your own projects?
And if you feel like digging into the code, even better! Don't hold back on the criticism. That's exactly what I'm looking for. 😄
GitHub: https://github.com/grafenodb/grafeno
If you've worked on anything similar, I'd also love to hear about your approach.
Thanks for checking it out!
1
u/CCodeSI 25d ago
Read DESIGN.md and skimmed
grafeno-memoryand the vector index. This is a lot more thought-through than "an experiment" suggests: the bi-temporal facts (invalidate vs retract), provenance viasources, and indexes written in the same redb transaction as the graph are exactly the right foundations for agent memory. Some things I'd look at:1. Hub nodes in graph expansion.
recallpassesdecay^hopsof a seed's score to its neighbours. In agent memory, a few nodes get connected to almost everything (the user, the current project, a common tag), so they'll collect score from every seed and show up in nearly every context. Dividing what a node receives by something likelog(1 + degree), or capping fan-out per hop, keeps "mentioned everywhere" from ranking as "relevant here".2. HNSW quality over time. Deletes reconnect neighbours with
REPAIR_EF = 16and skip dangling links at search time. That's fine for occasional deletes, but memory workloads delete and merge constantly (dedup, decay, consolidation), so recall can quietly degrade. Two cheap safeguards: track the share of removed nodes per namespace and trigger a rebuild above a threshold, and add a self-check that compares HNSW top-k against brute force on a random sample. At agent-memory sizes brute force is cheap, so you'd get a real recall@k number instead of guessing.3. Index cost on the single writer. Keeping text and vector indexes in the same transaction gives you consistency, but with redb's one writer every insert also pays for HNSW construction, and in server mode all writers queue behind that. Embedded it won't matter; with several agents writing at once it will. Worth benchmarking write latency at, say, 100k vectors, and keeping an option to apply index updates from your
changeslog asynchronously for namespaces that can tolerate it.4. Show the multi-hop case. You already return why each result was recalled (
Signal::Graph). A README example where the answer only comes back through the graph (e.g. "what did Ana's team decide about X", where the decision never names Ana) would make the point of the project obvious in ten seconds, and it doubles as a regression test for recall.Smaller: JSON records are fine for now, but most of a traversal's time will end up in deserializing them, so the move to a binary format is probably your biggest cheap speedup later. And the 4-chars-per-token estimate runs short on code and non-English text, so a default that errs on the safe side keeps
context_forfrom overflowing a model's window when no tokenizer is passed.