DEV Community

N3MO
N3MO

Posted on

Ai agents kept get in the loop of hallucination, so i resolved it

I love using AI coding agents. But recently, I noticed a frustrating pattern when asking them to execute complex, multi-file refactors.

I would ask an agent to modify a core utility function—let's call it validate_session(). The agent would enthusiastically rewrite the function, and then confidently hallucinate dependencies. It would tell me it updated files that didn't exist, or completely miss the downstream API endpoints that relied on the old function signature.

The problem wasn't the LLM's intelligence. The problem was how it was retrieving context.

When an AI agent (or even a human developer) searches a codebase, we rely on vector embeddings or basic substring matching (grep). But code isn't just a collection of text documents. It's a highly structured, relational graph.

When you modify validate_session(), you don't care where the string "validate_session" appears in a random markdown file. You care about:

  1. What function calls it?
  2. What functions call that function?
  3. What is the ultimate downstream impact?

I needed something that didn't guess.

Building the Map

I realized that if I wanted to truly understand the transitive blast radius of a change, I needed to parse the actual structure of the code, not just text.

So I built N3MO.

Instead of relying on embeddings, N3MO uses Tree-sitter (the exact same parsing engine GitHub uses) to parse source code into Abstract Syntax Trees (ASTs) locally.

It takes those ASTs and maps every function, class, and method into a queryable relational database. There are zero LLM calls during the indexing phase—it is pure, deterministic static analysis.

Scaling it Up

Initially, I tested it on small projects. But I wanted to see if a relational graph could handle enterprise scale without falling over.

So, I threw the TensorFlow codebase at it.

  • Files: 14,611
  • Symbols extracted: 79,523
  • Relational edges mapped: 480,851

N3MO parsed and indexed the entire repository into a queryable local graph in just 14.06 minutes.

Built for Engineers, Not Just Bots

I didn't just build this for AI. I built it to act as a structural insurance policy for human engineering teams.

Now, instead of running a slow grep and getting hundreds of noisy text matches, you can use N3MO to completely map your repository:

  1. The CLI: Run n3mo impact "validate_session" in your terminal to instantly see the full blast radius before you touch the code.
  2. CI/CD PR Bots: Hook N3MO into GitHub Actions. On every Pull Request, N3MO automatically calculates the blast radius of the modified files and drops a markdown report directly into the PR comments. You know exactly what will break before you merge.
  3. Interactive Visualizer: Boot up the local dashboard and visually explore the orbiting call graph to untangle massive legacy repos.

Giving the Map Back to the AI

Of course, once I had a deterministic graph, I couldn't resist giving it to the AI agents that inspired it in the first place.

I wrapped the N3MO engine in a native Model Context Protocol (MCP) server. Now, when I use Cursor or Claude Desktop, the agent can actively query the N3MO server alongside its normal workflow.

Instead of guessing context, the agent asks N3MO: "What is the transitive blast radius?" And N3MO hands back the exact, verifiable relational graph. No more hallucinations. Just surgical, structural precision.

Try it out

I'm building N3MO in public, and it currently supports deep semantic call graph mapping for Python, JS/TS, and Java (with structural parsing for 24 other languages).

If you want to stop guessing what your code touches whether you are a human or an AI give it a shot.

🔗 Star N3MO on GitHub
🌐 Visit the Website


bash
# Get started instantly
pip install n3mo
n3mo index /path/to/your/repo
n3mo query callers "my_function" --depth 5
Enter fullscreen mode Exit fullscreen mode

Top comments (0)