DEV Community

Cover image for I Built a Rust Engine to Stop AI Coding Agents from Wasting Tokens
yoosef alipour
yoosef alipour

Posted on Edited on

I Built a Rust Engine to Stop AI Coding Agents from Wasting Tokens

Your AI Coding Agent Doesn't Need More Context. It Needs the Right Context.

AI coding agents are powerful, but they have a context problem.

Ask an agent to fix one function in a large repository and it may read thousands of lines of unrelated code.

That means:

  • πŸ’Έ More tokens
  • 🐌 Slower responses
  • 🧠 More irrelevant context
  • πŸ” More chances to miss the important code

NeuroMesh takes a different approach:

Don't delete context. Fold it.

How It Works

NeuroMesh builds a live graph of your codebase β€” files, functions, imports, calls, and symbols.

When an agent receives a task, NeuroMesh:

  1. Finds relevant symbols.
  2. Routes through the code graph.
  3. Keeps important code expanded.
  4. Folds unrelated code into reversible markers.
  5. Sends a focused evidence packet to the model.

The code isn't deleted. If the agent needs a folded section, it can expand it on demand.

Why Not Just RAG?

Code isn't ordinary text.

Naive chunking can separate a function from its types, callers, imports, or dependencies.

NeuroMesh keeps the structure of the codebase intact and uses that structure to decide what the model actually needs.

Its approach combines:

πŸ•ΈοΈ Graph-based routing

🧬 Smart code folding

🧠 Learning from successful edits

⚑ Context prefetching

πŸ›‘οΈ Task-aware context budgets

The biology-inspired names β€” Physarum, synaptic learning, membranes, and mycelium β€” describe the ideas behind the system.

The goal is simple:

Find the path first. Send the useful code second.

Real Numbers

NeuroMesh v0.9.0 includes benchmarks on a 650k-token monorepo.

Task Before Fold Packet Reduction

Fix MCP tool handler 72,428 17,389 97.3%
Trace graph routing 19,625 4,080 99.4%

These are task-specific measurements, not a universal compression claim. You can run neuromesh eval on your own repository.

Local-First + MCP

NeuroMesh runs locally as a native Rust application and exposes its context engine through MCP.

It works with tools and environments including Cursor, VS Code, Claude, Codex, OpenCode, Windsurf, Zed, Cline/Roo, Gemini CLI, and more.

No cloud service is required for indexing, and your code stays on your machine.

Get Started

Installation, MCP configuration, supported agents, benchmarks, architecture, and the complete documentation are available here:

πŸ‘‰ https://pinoox.github.io/neuromesh

Or check out the source:

πŸ‘‰ https://github.com/pinoox/neuromesh

Ship less context. Ship the right code.

If you're using an AI coding agent today, are you giving it more context β€” or better context?

Top comments (0)