Habr AI→ original

How a developer cut an AI agent's token consumption by 4.6M per day: analyzing the leak

Most assume AI agent tokens are spent on complex tasks — code, website analysis, browser operations. But the real leak hides in background processes: cron…

AI-processed from Habr AI; edited by Hamidun News
How a developer cut an AI agent's token consumption by 4.6M per day: analyzing the leak
Source: Habr AI. Collage: Hamidun News.
◐ Listen to article

A developer on Habr published an analysis of real AI agent token consumption and discovered: the main budget goes not to useful work but to background utility processes. By adjusting these task settings, he reduced consumption by approximately 4.6 million tokens per day.

Where tokens actually leak

Intuition suggests that tokens go where the agent solves difficult tasks: writing code, analyzing websites, managing browsers, parsing logs. Complex task, model thinks, tools run, context grows—seems logical.

But analysis of real data shows a different picture. The main budget consumer isn't complex tasks but utility processes that run in the background constantly:

  • Cron jobs — regular launches regardless of whether there's actual work or not
  • Diagnostics and status requests — the agent constantly checks its state, even when nothing is happening
  • Excessive tool lists — dozens of tools are loaded into context "just in case," though most tasks require only three to five
  • Monitoring checks — continuous health pings, including during periods of complete idle time

The paradox is that the agent reliably performs its work from a code perspective: it runs checks, keeps tools at hand, executes schedules. Only none of these actions create value for the user—yet each one adds to the bill. The token counter starts spinning before the user even sends a single request.

Why this leak is hard to spot

The author describes the situation with a perfect analogy: imagine a contractor called to replace one outlet. Before picking up tools, he unloads the entire construction market from his van, two drills, and a concrete mixer—and bills for all the time, including unloading.

Each individual background request seems cheap: a diagnostic ping—dozens of tokens, a cron check once per minute—also not much. But on a daily scale, with several parallel processes, the cumulative effect is enormous—comparable to thousands of real user interactions.

The problem is compounded by the standard approach to designing agent systems: everything potentially useful is loaded into context upfront, tools are attached in bundles, monitoring runs continuously. At the development and debugging stage, this is justified. In production it becomes a permanent and predictable hole in the budget. That's why the problem doesn't stand out at first glance at expenses: the dashboard shows the sum but doesn't explain where most of it comes from.

What background process audit gives

The developer identified specific leak points, adjusted background task settings, and reduced consumption by approximately 4.6 million tokens per day. Important: this is the result only on background tasks—without any changes to the agent's core work logic.

Optimization of AI agents doesn't start with prompt quality and isn't determined by model choice. A significant part of the real budget is determined by architectural decisions—frequency of background launches, composition of tools in context, monitoring logic. This is often where the fastest and most measurable cost-saving opportunities lie. Such an audit is especially important when scaling: increasing the number of agents or tasks multiplies background consumption even if the core logic remains unchanged.

What this means

Before optimizing the quality of an agent's responses, check how many tokens are spent before it starts working. Auditing background tasks isn't a one-time measure—it's a standard part of maintaining agent systems in production.

ZK
Hamidun News
AI news without noise. Daily editorial selection from 400+ sources. A product by Zhemal Khamidun, Head of AI at Alpina Digital.

Want to stop reading about AI and start using it?

AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.

What do you think?
Loading comments…