AgentsBusiness & Market 🇷🇺 31.07.2026 17:02

One agent step — 120,000 tokens: where they go and how we fixed it

An autonomous agent can consume far more tokens than expected due to the repeated sending of the full context on each step of the agent loop. The article describes how Uma Computer found that the real cause was not the dialogue history, but the multiplied overhead of system instructions, tool schemas, and memory, and presents three optimizations: moving volume to on-demand tools, switching to a character budget with explicit truncation markers, and transparent speed expectations.
The developers of Uma Computer, an autonomous agent that performs tasks like web search, media generation, and video clipping, investigated why one user request cost 38 credits instead of the expected third of that. Billing showed 119,208 prompt tokens and only 1,018 completion tokens, meaning the model was mostly reading, not writing. The initial hypothesis was a long dialogue history, but the actual problematic dialogue had only two messages totaling 530 characters. Measurement revealed that the context per step was 13,900 tokens, and with 9 steps the total reached about 120,000 tokens; the overhead multiplied by the number of steps in the agent loop. Additionally, the provider reserves the worst-case cost with max_tokens set high, causing HTTP 402 errors even with sufficient balance. The fix involved moving preloaded context to on-demand tools, using a character budget with priorities and explicit truncation markers, and making speed expectations transparent. The article emphasizes that context should never be silently hidden from the model, and that optimizations should be verified on concrete cases, as they almost optimized for a case where history was irrelevant.
Abbreviations
MCP = Model Context Protocol — протокол контекста модели
LLM = Large Language Model — большая языковая модель
API = Application Programming Interface — программный интерфейс приложения
HTTP = Hypertext Transfer Protocol — протокол передачи гипертекста
Docker = Docker (containerization platform) — платформа контейнеризации
Source: Habr — хаб ML — original
Our earlier posts on this topic ↓
Fresh news