Cut 90% of Tokens for Coding Agents with AST Context Graphs

Remarkable-One9371 · reddit · 2026-07-05

The author experimented with a local-first coding agent context service that builds a code repository graph based on AST/LSP-style facts: indexing files, symbols, imports, calls, definitions, containment relationships, and dependency edges. This allows the agent to query relevant subgraphs first, falling back to raw files, search, or LSP only when evidence is insufficient.

In benchmarks, graph context reduced input tokens by about 90% compared to broad snippets, while answers remained solid. The author emphasizes that "graph-first" does not mean "graph-only"; when retrieval is too narrow, the agent still needs to fall back to reading and verifying source code. They also welcome discussions on the trade-offs between LSP-first, embeddings/RAG, graph retrieval, or hybrid approaches.

Original post →

More from coding & agent

coding & agent channel →