agent-brain MCP server compresses codebases ~85% to cut context waste
u/Sherbet-Beneficial built agent-brain, an MCP server using a custom SAN compression format that reduces source files from ~1,200 to ~150 tokens (~85%), so reasoning models in agent loops spend less context re-reading boilerplate and more on actual reasoning.
Score breakdown
The tool directly addresses a concrete bottleneck in agentic coding loops — context budgets consumed by redundant file re-reads — by fitting entire repositories into context that previously only held a fraction of the codebase.
- 01SAN (Structured Associative Notation) compresses source files from ~1,200 to ~150 tokens, roughly an 85% reduction.
- 02Raw source code is described as ~90% braces, imports, and boilerplate — the primary source of wasted context.
- 03A repo that previously fit ~15% into context can now fit in full after SAN compression.
u/Sherbet-Beneficial built agent-brain after repeatedly hitting context limits while running coding agents with Fable, a deep reasoning model. The problem: in an agent loop, the model re-reads the same source files every turn, and raw code is described as roughly 90% braces, imports, and boilerplate — meaning most of the context budget was consumed by stale code rather than active reasoning.
The solution is SAN (Structured Associative Notation), a compression scheme that reduces each source file from approximately 1,200 tokens to ~150 tokens, an ~85% reduction.
The solution is SAN (Structured Associative Notation), a compression scheme that reduces each source file from approximately 1,200 tokens to ~150 tokens, an ~85% reduction. The v2 format preserves identifiers verbatim and includes `src:` line anchors, so when the agent needs exact code it can reference real line numbers rather than guessing. A repo that previously fit only ~15% into context can now fit in full.
Beyond compression, agent-brain includes a persistent decision-memory layer that logs decisions and rejections across sessions and provides a `pre_check` mechanism to prevent the agent from repeating past failures. The author describes this memory layer as the part they are least confident about and explicitly invites scrutiny. The project is open-source on GitHub and the author is seeking contributions, particularly on expanding SAN compiler support for more languages and evaluating whether the memory layer is justified or over-engineered.
Key facts
- 01SAN (Structured Associative Notation) compresses source files from ~1,200 to ~150 tokens, roughly an 85% reduction.
- 02Raw source code is described as ~90% braces, imports, and boilerplate — the primary source of wasted context.
- 03A repo that previously fit ~15% into context can now fit in full after SAN compression.
- 04The v2 SAN format preserves identifiers verbatim and includes `src:` line anchors for call-site accuracy.
- 05A persistent decision-memory layer logs decisions and rejections across sessions with a `pre_check` step to avoid repeating past failures.
- 06The project is open-source at github.com/sandeep84397/agent-brain and seeking contributions.
- 07The author is specifically requesting feedback on the SAN compiler's multi-language support and whether the memory layer is over-engineered.
Topics
Summary and scoring are generated automatically from the original article. We always link back to the publisher and never republish images or paywalled content. Last processed Jun 12, 2026 · 10:05 UTC. How this works →