Independent research · 2025

Cutting the token waste inside AI coding agents

Minimal sufficient retrieval for repository-level code intelligence, using a Variational Graph Information Bottleneck over a code knowledge graph.

RetrievalCode intelligenceResearchGNN
60–80% token waste targeted
VGIB subgraph selection
Code graph retrieval substrate

The short answer

AI coding agents waste 60% to 80% of their token budget navigating codebases with blind shell commands such as grep, find and cat. Token Sniper replaces that with learned retrieval over a code knowledge graph. I formalised the problem and used a Variational Graph Information Bottleneck to select the minimal, maximally informative subgraph for the model. The repository is private; the method and results are available for a walkthrough.

Context and role

ContextIndependent research · 2025
RoleSole author.
CategoryIndependent research

The problem

Repository-level code generation is limited by context. Agents that explore with shell commands spend most of their token budget on files and lines that never influence the answer.

Throwing the whole repository into the context is expensive and often worse, because the relevant signal is diluted.

The useful question is not "how do we retrieve more code" but "what is the smallest subgraph that still contains the answer".

Approach

  • Represented the repository as a code knowledge graph.
  • Formalised the retrieval problem as finding a minimal, maximally informative subgraph for the generation task.
  • Applied a Variational Graph Information Bottleneck (VGIB) to select that subgraph.
  • Validated the hypothesis that repository-level code generation improves when the model receives the selected subgraph rather than raw repository context.

What I did not claim

The boundary of a project is part of its evidence. These are the claims this work does not support.

  • The repository is private. There is no public benchmark leaderboard entry.
  • This is research, not a shipped developer product.
  • No claim of production deployment or user numbers.
  • The finding is a research result, not a guarantee that every agent will improve by the same amount.

Results

  • Formalised and validated the minimal sufficient retrieval hypothesis for repository-level code generation.
  • Built an implementation using a code knowledge graph and VGIB subgraph selection.
  • The method targets the 60% to 80% token-budget waste caused by blind navigation in agents such as SWE-agent and Cursor.
  • The private repository can be walked through on request.

Stack

  • Python
  • Graph neural networks
  • Variational Graph Information Bottleneck
  • Code knowledge graphs

What this means for you

The useful part of this project is not the artifact. It is the method: define the measurement first, keep the scope honest, and hand over something your team can run. That method is what transfers to a new problem.

If your situation looks similar, the related services below are the place to start. If it does not, send a short description and I will tell you whether I am the right person.

Boundary: Independent research. The repository is private and no production deployment is claimed.

Written by

Marius Boroica is an independent AI automation engineer in Cluj-Napoca, Romania. He designs AI workflows, document pipelines and internal assistants, and connects them to the tools a team already uses. NVIDIA Certified Professional: Gen AI LLMs.

Page last updated: October 2026

Next step

Have a problem in the same shape?

A 30-minute call is enough to see whether the method transfers, and which engagement is the smallest useful one.

Prefer email? [email protected]