The Architecture of Persistent Agent Memory

GBrain addresses the common limitation of AI agents: the lack of persistent, structured memory across sessions. Developed by Garry Tan to power his own agent deployments, it functions as a markdown-first knowledge layer. The system uses PGLite (Postgres compiled to WASM) to provide a serverless, local database that supports vector search, BM25 keyword search, and a typed knowledge graph. By maintaining a "compiled truth + timeline" pattern in markdown files, it ensures that human-readable documentation remains the system of record while the agent maintains a high-performance retrieval layer.

Deterministic Knowledge Graph Extraction

A core innovation of GBrain is its ability to wire a knowledge graph without LLM calls. It uses a regex-based inference cascade to extract typed edges (e.g., works_at, founded, invested_in) directly from wikilinks within markdown files. This structural approach allows for precise, one-hop traversals rather than relying solely on vector similarity. Benchmarks on the "BrainBench" corpus demonstrate that this graph-enabled retrieval provides a +31.4-point P@5 lead over vector-only search, achieving 49.1% P@5 and 97.9% R@5.

Integration and Autonomy

GBrain is designed for seamless integration with modern AI development workflows. It exposes 74 tools via the Model Context Protocol (MCP), allowing agents like Claude Code, Cursor, and Windsurf to read, write, and query the brain directly. The system also includes an "autopilot" mode that manages health scores and remediation tasks via a cron-driven daemon. For production scaling, GBrain supports migrating from the local PGLite instance to a full Supabase or Postgres backend, ensuring it can grow from a small personal repository to a large-scale knowledge base.