After open-sourcing gstack (23 Claude Code specialist roles), Y Combinator CEO Garry Tan released GBrain β a self-wiring knowledge graph that gives AI agents persistent memory. Your agent ingests meetings, emails, tweets, voice calls, and ideas. It enriches every person and company it encounters. It fixes its own citations overnight. You wake up and the brain is smarter than when you went to bed.
The Problem: Agents Are Smart but Forgetful
LLM agents lose context between sessions. They can reason about what you tell them right now, but they cannot recall what happened last week, who you met, or what decisions were made. RAG (Retrieval-Augmented Generation) helps, but pure vector search misses relational queries like βwho works at company X?β or βwhat did this investor fund this quarter?β
GBrain solves this with a hybrid approach: vector embeddings for semantic search plus a structured knowledge graph with typed entity links. Every page write extracts references and creates relationships (attended, works_at, invested_in, founded, advises) β with zero LLM calls for the graph wiring.
Architecture
GBrain runs on PGLite β an embedded PostgreSQL that starts in 2 seconds with no server. The stack:
βββββββββββββββββββββββββββββββ
β AI Agent (OpenClaw/Hermes) β
βββββββββββββββββββββββββββββββ€
β MCP Tools (30+ exposed) β
βββββββββββββββββββββββββββββββ€
β Hybrid Search Engine β
β βββ Vector (embeddings) β
β βββ BM25 (keyword) β
β βββ Graph (entity links) β
βββββββββββββββββββββββββββββββ€
β PGLite (embedded Postgres) β
βββββββββββββββββββββββββββββββInstall and first query in under 2 minutes:
git clone https://github.com/garrytan/gbrain.git
cd gbrain && bun install && bun link
gbrain init # Local brain, ready in 2 seconds
gbrain import ~/notes/ # Index your markdown files
gbrain query "what themes show up across my notes?"The query returns ranked results with scores and source attribution β not hallucinated summaries.
Self-Wiring Knowledge Graph
This is the feature that separates GBrain from standard RAG pipelines. When you write a page about a meeting with βAlice from Acme AI,β GBrain automatically:
- Extracts entities: Alice (person), Acme AI (company)
- Creates typed links: Alice
works_atAcme AI - Links the meeting page to both entities
- Indexes for hybrid search
No LLM calls required for extraction β it uses pattern matching and structured metadata. The graph enables queries that vector search alone cannot answer:
- βWho works at Acme AI?β β follows
works_atlinks - βWhat companies did Bob invest in this quarter?β β follows
invested_inlinks with date filtering - βShow me everything connected to the Series A roundβ β traverses the graph from the event node
Benchmarks
Tan published benchmarks comparing GBrainβs hybrid search against alternatives on a 240-page Opus-generated corpus:
| Method | Precision@5 | Recall@5 |
|---|---|---|
| GBrain (graph + vector + BM25) | 49.1% | 97.9% |
| GBrain (graph disabled) | 17.7% | β |
| ripgrep-BM25 + vector-only RAG | ~18% | β |
The graph layer and entity extraction together account for a +31.4 point improvement in precision. Full evaluation methodology and corpus are in the gbrain-evals repo.
MCP Integration
GBrain exposes 30+ tools via the Model Context Protocol, making it accessible to any MCP-compatible agent:
{
"mcpServers": {
"gbrain": { "command": "gbrain", "args": ["serve"] }
}
}Works with Claude Code, Cursor, OpenClaw, Hermes, and any MCP client. For production, gbrain serve --http starts an OAuth 2.1 server with an admin dashboard β zero external infrastructure.
34 Built-In Skills
GBrain ships with 34 skills that automate brain maintenance:
- Entity enrichment β automatically research and expand person/company profiles
- Citation repair β fix broken references and update sources overnight
- Memory consolidation β merge duplicate entries, resolve conflicts
- Cron jobs β 21 autonomous recurring tasks that keep the brain current
Tan runs 21 cron jobs on his personal deployment. The brain maintains itself β deduplicating entities, updating stale information, and enriching profiles without manual intervention.
Scale: Tanβs Production Numbers
The production brain powering Tanβs OpenClaw and Hermes deployments:
- 17,888 pages indexed
- 4,383 people with enriched profiles
- 723 companies with relationship graphs
- 21 cron jobs running autonomously
- Built in 12 days
This is not a toy demo. It is the actual infrastructure running YCβs CEOβs AI workflow.
My Take
GBrain fills the biggest gap in the AI agent ecosystem: persistent, structured memory. Most agent frameworks treat memory as an afterthought β append-only logs or basic vector stores. GBrain treats it as a first-class knowledge system with graph relationships, hybrid search, and self-maintenance.
The PGLite choice is smart β no Postgres server to manage, no Docker containers, no cloud database. The brain starts in 2 seconds on your laptop. For teams, the HTTP server with OAuth 2.1 provides production-grade access control.
If you are running any kind of AI agent (OpenClaw, Hermes, custom) and need it to remember context across sessions, GBrain is worth the 30-minute install.
Related Reading
- Garry Tanβs gstack: 23 Claude Code Specialists
- Karpathyβs CLAUDE.md: 4 Rules That Fix LLM Coding
- Context Architecture for AI Agents
- RAG vs Fine-Tuning for Enterprise AI
Build Your Own AI Agent Memory
GBrain is just the beginning. Master the tools that power it:
- π Claude Code Masterclass (Free on Udemy) β Learn CLAUDE.md, hooks, and autonomous agent patterns
- π Claude Code Companion Book (Leanpub) β Enterprise AI agent workflows and memory architectures
- π GBrain Tutorial: Build a Self-Wiring Memory Layer β Hands-on implementation guide