The 5,671-Token Greeting: Inside One Developer's Audit of Agent Token Costs
Agent cost overruns are usually invisible: total token counts hide how many calls a turn triggers and how much context each call carries. This audit shows that tracing individual calls, splitting responsibilities, and agreeing on a success standard before optimizing are what actually keep agent costs predictable and debuggable.
Workrun's main agent was designed as a single capable entry point: understand the user, answer, call tools, route to plans, and orchestrate. That design broke down in practice when a plain greeting burned 5,671 tokens and nobody could explain why. The author traced the cause by giving up on aggregate stats and instrumenting individual model calls through Langfuse, reusing the existing OpenTelemetry layer. Observability revealed a bloated context that carried responsibilities far beyond the immediate question.
The fix was structural, not cosmetic. The main agent was split into a lightweight router that only decides between conversation, task, and workflow, while the agent that actually does the work retains the full input. Splitting introduced a second call per ordinary turn, so savings aren't automatic. More importantly, the author found that shorter prompts can backfire: when the model lacks configuration knowledge, it queries tools, pulls results into context, and triggers extra rounds, so total consumption can rise even with a trimmed prompt. The right move was providing node contracts and summaries at the right stages instead of simply withholding information.
Cost control also required knowing what "success" means. The author defines three checks before comparing token counts: orchestration must be grounded in the platform's actual node contracts, the artifact must match the user's stated requirements, and validation must only claim what was actually executed. Only after those are satisfied does it make sense to compare usage, duration, and repair counts across model calls.
Total token usage is a poor health metric for agents because it conflates the number of calls with the size of each call; per-call tracing exposes the real cost driver.
A router that always requires two calls can still be cheaper than one call with huge context, but only if the router never misroutes; a wrong path is the expensive failure.
Shorter prompts are a trap when they push the model into tool queries; the more effective pattern is to make existing knowledge readily available at the moment it's needed.
Discipline in defining what counts as success is what makes token optimization a real engineering process instead of a game of whack-a-mole.
The author's decision to avoid a generic model capability detection framework shows that scoping fixes to actual failures is more valuable than speculative abstraction.
The example of the grading logic taking the wrong path is more worth remembering than the 5,671 number — "give plan first" was treated as a general consultation, and the model asked back which platform you use, which shows that when routing goes wrong once, all the tokens saved are fake savings. I agree with the boundary 'Plan first, do not create yet and do not execute restrict later actions; they do not turn a Workflow request into a general chat', but I want to ask: is this boundary currently only written in the Router's prompt, or has it been turned into a regression test case? Boundaries in prompts are easily diluted by the next round of requirements; regression test cases are what guarantee it won't quietly drift off course.
Currently there is automated test coverage, but we still need to improve the evaluation system to keep checking this kind of routing boundary.