Skip to content

Your Coding Agent Wastes SO MANY Tokens Just Finding Code - Here's the Fix

Read the Portuguese translation →

Author: Cole Medin · Watch on YouTube

Video authored by the channel shown, not by IANIA; all rights belong to the creator. Transcript and summary generated automatically; the original-language content is preserved.

Original language: English

Original video: Your Coding Agent Wastes SO MANY Tokens Just Finding Code - Here’s the Fix · Channel: Cole Medin · 02:11 · Watch on YouTube

Topics: AI agents, AI developer tools, Model inference and optimization, RAG, search and information retrieval

Coding agents spend substantial time and tokens searching codebases and reading files before making changes, and searches can miss relevant code when names differ. Sonar Vortex addresses this with direct lookups in a code graph, identifying relationships such as which classes implement an interface or call a function. The video demonstrates using it with a coding agent and says its graph runs locally and refreshes quickly after edits. A Sonar study found token savings of 6% to 34% across six refactoring tasks, and semantic navigation currently supports six programming languages.

  • Finding relevant code can consume more of a coding agent’s effort than writing the change itself.
  • Reading search results uses context before the agent edits any code.
  • Search can miss relevant code when it is named differently from what the agent expects.
  • Sonar Vortex provides direct code lookups using information from a codebase graph.
  • It can identify relationships such as interface implementations, function callers, and callbacks down to the file and line.
  • The graph is built on the user’s machine and refreshes in about a millisecond after an edit, according to the video.
  • The example compares an initial search that took 80,000 tokens with a Sonar Vortex lookup and follow-up context load that used about the same number of tokens as the lookup.
  • A Sonar study reported token savings between 6% and 34% across six refactoring tasks run 10 times.
  • Semantic navigation supports Java, C#, JavaScript, TypeScript, Python, and Rust, and runs on SonarQube Cloud with the Sonar Agent Essentials add-on.
Start Chapter Summary
00:00 Why coding agents spend tokens finding code The video explains that agents spend time and context searching files before editing, and that search can overlook relevant code.
00:34 Introducing Sonar Vortex Sonar Vortex is presented as a tool for directly identifying code relevant to a requested change.
01:07 Direct lookups with a local code graph The demonstration shows Vortex identifying code relationships and using a locally built graph that refreshes quickly after edits.
01:40 Token savings and supported languages The video compares token use, reports Sonar’s study results, and lists the languages and Sonar product requirements.

Most of what you pay a coding agent for isn’t actually writing code. — 00:00

searching is a guess. — 00:34

It is much more efficient. — 01:07

it took 80,000 tokens just to do this searching. — 01:40

the token savings was anywhere between 6 and 34%. — 02:11

Sonar Vortex, Sonar, SonarQube Cloud, Sonar Agent Essentials, navegação semântica, tokens, Cole Medin

00:00 Most of what you pay a coding agent for isn’t actually writing code. It’s finding the right code to edit in the first place. Seriously, if you ask your coding agent to change anything in your code base, as long as it’s not trivial, look what happens. It spends so much time searching and reading through all the files it finds to make sure they apply. And the search itself is fast and cheap, but reading through all these files, it takes so much context here before you’re even changing a single line of code. And it’s not just the cost. searching is a guess. And so, if you have something the agent should have

00:34 changed, but it’s named differently than what the agent is looking for, you’re just going to miss it. And so, the change might be correct for everywhere that it identified, but that isn’t always good enough. Now, underneath all of this, your agent is just answering a single question. What code applies here for the change the user is requesting. The problem is, coding agents can’t answer that directly, but there is a tool that can, and it’s called Sonar Vortex. And so, Sonar is a platform I’ve covered a lot on my channel already. It already parses your code base. And so, now Sonar Vortex is a tool on top that

01:07 solves our problem here. It’s able to identify for us very efficiently and directly things like what classes implement an interface, what calls a function, and what it calls back, down to the file and line. So, now I’m back over in Cloud Code with the same prompt, but this time giving it access to Sonar Vortex. To show you here that it is a direct lookup instead of a search. It is much more efficient. And the graph that it uses to perform the lookups is built right on our machine. There’s no compiler or language server, and it refreshes in about a millisecond after any edit, which is a big deal for me

01:40 because generally halfway through an agent turn, your code base hasn’t compiled yet. So, in our original conversation, after it did all of the searching and reading all the files, it took 80,000 tokens just to do this searching. But now, over to the second one with Sonar Vortex, I was able to do the same lookup and then even a follow-up prompt to load more context, and it still was about the same number of tokens that it took. So, it’s definitely more efficient. Sonar did a study where they ran six refactoring tasks across 10 runs, and they figured out that the token savings was anywhere

02:11 between 6 and 34%. Semantic navigation covers Java, C#, JavaScript, TypeScript, Python, and Rust right now. It runs on SonarQube Cloud with the Sonar Agent Essentials add-on. Thanks to Sonar for working with me on this, and I’ll have a link to Sonar Vortex in the description.