I tested AST-backed context graphs for coding agents; here is what changed

Reddit r/AI_Agents Tools

Summary

Experiment shows AST-backed context graphs for coding agents can reduce token usage by 90% compared to broad snippets, while maintaining grounding, with a hybrid approach recommended to handle narrow retrieval cases.

I have been experimenting with a local-first context service for coding agents that builds a repo graph from AST/LSP-style facts instead of making the agent start with broad file search. The useful pattern so far: - index files, symbols, imports, calls, definitions, containment, and dependency edges - let the agent query the relevant subgraph first - expand to raw files, search, or LSP only when evidence is weak - measure not only token count, but also whether the retrieved context would increase hallucination risk In one benchmark pass, graph context used about 90% fewer input tokens than broad snippets while keeping the answer grounded enough for the tested tasks. The important caveat is that graph-first cannot mean graph-only. If retrieval is too narrow, the agent has to fall back to source reads and validation. I'm curious how others are handling this for coding agents: do you prefer LSP-first retrieval, embedding/RAG retrieval, graph retrieval, or a hybrid?
Original Article

Similar Articles

I built an Code context graph for Agentic Coding

Reddit r/ArtificialInteligence

The author built a code context graph parser that creates a graph from static analysis and exposes it via MCP for AI agents. In a head-to-head comparison with Gemma 4 26B, agents using the graph explored Apache Kafka's request flow in under 2 minutes, while the baseline agent without the graph ran out of rate limits in 6 minutes.