---
id: 18938
lang: en
title: "AI Agent Hunts for Load Bugs With and Without Code: 0.19M Tokens per Bug"
published_at: "2026-12-02 08:32:48"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1114758/?utm_campaign=1114758&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18938"
categories: ["llm", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# AI Agent Hunts for Load Bugs With and Without Code: 0.19M Tokens per Bug

> **Краткая суть (BLUF):** An AI agent was asked to load-test a Go voice service, once with the source code and once with only the API and documentation. The work is billed in tokens, the chunks of text the model reads and writes. The agent with code found 8 bugs for 1.5M tokens, while the agent without code found 10 for 1.9M, which works out to roughly 0.19M tokens per bug in both cases. So the choice of approach should depend on the type of bugs you expect, not on cost.  - With code, 6 of 12 common problems were confirmed; without code, 4 - Only the agent with code found the quadratic growth in the queue - Two-thirds of the tokens go to re-reading context, and responses account for 2%

AI-written code often works in a demo and falls apart under load: queries inside loops, caches with no bounds, connections without timeouts. You can also set AI agents to load testing, but then the question becomes cost. You pay in tokens, the chunks of text the model reads and writes, and the bill grows with every step the agent takes. Developer Dmitry Fedotov tested two approaches on his own Go voice service, Kontakt. In the first, a white-box setup, the agent reads the source code and looks for problems directly in it. In the second, a black-box setup, there is no code, only the API, the interface and the documentation. In the end, both approaches spent about 0.19M tokens per bug found, but they searched for different things.

## How the experiment was set up

Kontakt is a calling service with WebSocket for a web handset, SIP over UDP for softphones, and several HTTP endpoints. The code was written with an AI agent. Both sessions were run by the same model, Claude Opus 5.5, each in a new chat without memory and on a fresh test bench with 2 vCPU and 8 GB of RAM. Load was applied only through the external API.

So the agent would not run load tests at random, it was given a catalog of 12 typical performance problems: queries in loops, no pagination, quadratic growth of time with data volume, unbounded caches, missing timeouts, retries without a pause, no per-client limits, and so on. A problem counted only if a real load run confirmed it.

Spending was reduced to a single figure by converting everything into the price of a regular input token: a cache read costs 0.05 of that, a cache write costs 2, and a model response costs 5.

## What each approach found

The black-box agent received the documentation directly in its task: README, test cases, reports. It found 10 bugs and confirmed 4 of the 12 common problems. It used about 1.9M tokens, 82 model requests and 1 hour 7 minutes. Among the findings was a moderation database that was rewritten on disk: while bans were being appended to it, the 95th percentile call setup time (the time beyond which the slowest 5% of calls wait) grew 10.7 times. It also found a memory leak in the alert map, silent WebSockets that hang forever, and the absence of an RTP rate limit: one leg of a call forwarded 2000 packets per second instead of 50. Some hypotheses came from the documentation: the agent spotted the leak from the description of the alert limit and itself wrote that without that file the hypothesis would not have existed.

The white-box agent read 7 code files. It found 8 bugs and confirmed 6 common problems, using about 1.5M tokens, 69 requests and 1 hour 18 minutes. It alone caught the quadratic growth in the roulette queue: the code immediately showed how the queue worked, and the agent verified it over a range of up to 4000 waiting subscribers. The black-box agent concluded that such a queue could not be filled and ruled the problem out before running any tests. The white-box agent never opened the documentation: the prompt did not point to it, and it did not look for it on its own.

Together the two sessions found 11 distinct bugs. How many the service actually has is unknown. For each confirmed common problem, the white-box approach came out roughly twice as cheap.

## Where the tokens go and what follows

The spending structure is almost identical. Instructions and re-read context account for 61–67%: at every step the agent resends the entire history to the model. Files and commands, including code reading, take up about a third, and the agent's responses take about 2%. Reading code did not inflate the bill: the agent opened 7 files selected from the catalog, not the whole repository.

Practical takeaways:

- Work from a catalog of common problems. It turns a request to "test performance" into 12 specific questions.
- If you can give the agent the code, do so: it confirms more problems and sees the conditions under which they appear.
- Provide documentation explicitly, along with test cases and capacity reports. The agent will not come across it on its own.
- Treat "this isn't in the code" as a hypothesis. The white-box agent dropped four problems after reading the code without load testing, and only the black-box agent checked three of them (excess disk reads, missing pagination, retries without a pause). None were confirmed, but the check was necessary. Timeouts, limits and hung connections should be verified from the outside.

## Limitations

This is one service, one model and a single run per approach, on a small bench. The main caveat: the approaches received the documentation differently. The black-box agent read it first, while the white-box agent never opened it. So the experiment compares not only access to code but also two ways of framing the task for the agent, and the difference in bug counts cannot be fully attributed to either one. With documentation, the white-box agent might have found more, but this was not tested.

Not all findings carry the same weight. Re-reading the config every 500 ms is formally a bug and was counted, but on a real config it consumes only 0.07% of a core. If you cannot choose between approaches, run both: they catch different classes of problems. The white box covers scale and algorithmic issues, while the black box with good documentation finds what is not visible in the code.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1114758/?utm_campaign=1114758&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18938
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
