Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
GBrain - self-wiring knowledge graph for AI agents by Garry Tan
AI

GBrain: Garry Tan's Self-Wiring Knowledge Graph for AI

Y Combinator CEO Garry Tan open-sourced GBrain β€” a self-wiring knowledge graph that gives AI agents persistent memory. 17,888 pages, hybrid search, entity.

LB
Luca Berton
Β· 4 min read

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:

  1. Extracts entities: Alice (person), Acme AI (company)
  2. Creates typed links: Alice works_at Acme AI
  3. Links the meeting page to both entities
  4. 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_at links
  • β€œWhat companies did Bob invest in this quarter?” β€” follows invested_in links 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:

MethodPrecision@5Recall@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.

Build Your Own AI Agent Memory

GBrain is just the beginning. Master the tools that power it:

Free 30-min AI & Cloud consultation

Book Now