As a data analyst, I learned early on to care about query efficiency. We have all felt that pit in our stomach after accidentally writing a bad SQL join that scanned terabytes of data and spiked the monthly cloud bill. Today, as engineering teams race to build generative AI data agents, we are seeing a new version of this exact same problem.
When companies budget for AI, they usually look at the base API price for models like Opus 5.5, GPT-6.1 Sol, or Gemini 4. A fraction of a cent per token seems totally fine on paper. But token pricing only tells half the story. Newer and larger models are not always more efficient. Recent benchmarks even show that models like Opus 5 can burn significantly more tokens than previous versions just to complete the exact same task. When data teams finally put these agents into production, their monthly bills often explode.
You look at the logs and realize that a simple question like "Why did our gross margin drop in Q3?" did not cost a few cents. It cost two dollars and took 30 seconds to answer.
The root cause isn't that models are suddenly generating novel-length answers. The real bottleneck - and the real financial leak - is inefficient context management in a fundamentally stateless architecture.
The Reality of "Stateless" LLMs
To understand why bills explode, you have to dispel the prevailing illusion that an LLM has an active memory.
Large language models are completely stateless. They do not maintain an ongoing train of thought. They do not possess a background cache where they "remember" what you talked about two minutes ago. Every API call is an isolated mathematical transaction: tokens in, probabilities calculated, tokens out and that's it.
To create the illusion of a continuous, fluid dialogue, the client application has to do something brute-force: it must resend the entire history of the session back to the model on every single turn.
This is where the financial snowball begins.
It's not just tool calls that rack up the bill. Every time a user types a follow-up, every time they correct a mistake, and every time the agent asks for clarification, the entire transcript is re-packaged and re-sent over the wire:
- Turn 1 (Initial prompt + system instructions): 3,000 tokens.
- Turn 2 (Model tool call + raw database schema returned): 9,000 tokens.
- Turn 3 (User corrects: "No, calculate internal cost, not customer cost"): The model doesn't just read the 8 words. It re-reads the 3,000 token system prompt, the 6,000 tokens of raw schema, the initial query, and the correction. Total: ~12,500 tokens.
- Turn 4 (Second tool call + execution error returned): 18,000 tokens.
- Turn 5 (Final answer generated): 24,000 tokens.
By the fifth turn, you aren't paying for a conversational partner; you are paying a cloud provider to re-read an ever-expanding historical transcript from scratch.
The Blind Discovery Trap
The effect of statelessness can be even more costly when the agent goes on a data discovery expedition.
Today, most teams build agents by exposing their data warehouse, dbt docs, and Notion metrics through tools or MCPs. But if the agent doesn't have an upfront semantic map of your business, it behaves like an intern on their first morning: completely blind.
To answer "Why did margin drop?", it enters an unguided loop:
- Tool Call 1:
list_all_tables() - Tool Call 2:
describe_table(sales_mart_v2) - Tool Call 3:
search_docs("gross margin definition") - Tool Call 4:
describe_table(finance_adjustments)
Each step appends thousands of tokens of raw JSON into the transcript. Because the system is stateless, Call 4 is paying to process the JSON returned by Call 1, 2, and 3 - most of which turned out to be irrelevant anyway.
This invisible tax burns through token budgets. Worse, every call adds latency. Users are left staring at a loading spinner for 90 seconds while the AI blindly pings the company's infrastructure. In data analytics, if a tool takes 90 seconds to answer a basic question, users will simply abandon it and go back to their old dashboards.
The Manual Curation Nightmare
To fix this cost issue, some engineering teams try the opposite extreme: they manually copy their entire database schema and metric definitions into a huge text file and dump it into the system prompt upfront.
As an analyst, I can tell you this is a nightmare to maintain. The moment a column gets renamed or a dbt model changes, that static file is outdated.
It also introduces a lot of noise for the model, giving it information it won't need on every question - we rarely need the entire database for a single investigation. You end up paying for huge token payloads on every query, no matter how simple the user's question was.
The Real Solution: Just-in-Time Context Routing
Solving this issue requires treating context management as an infrastructure problem, not an LLM problem.
Instead of letting the model blindly search your systems or drowning it in a static schema dump, you need an intelligent intermediate layer that sits between the user and the LLM.
When a user asks a question, this intermediate layer intercepts it. Instead of spinning up an expensive LLM to blind-search the enterprise via MCPs, the layer maps the user's intent to the exact schemas, metric definitions, and behavioral rules required for that specific question. It instantly packages this highly optimized knowledge and hands it to the LLM.
For example, when a user asks: "Why did gross margin drop in Q3?", this intermediate layer intercepts the intent before the LLM burns a single token. It:
- Identifies the intent and detects that the query relates to the core_finance domain.
- Packages only the specific table schemas required for that query (e.g. Q3 revenue, returns, and COGS).
- Attaches the exact, version-controlled definition of "gross margin" from the semantic layer.
- Prunes historical turns and dead-end tool responses that are no longer relevant to the active question.
By handing the model the exact puzzle pieces upfront, you collapse a workflow that previously took 8 exploratory tool calls, 4 user corrections, and 50,000 tokens into a single, precise call consuming 2,500 tokens.
Smarter Infrastructure Beats Cheaper Tokens
Statelessness is a fundamental feature of modern LLM architecture, but unmanaged statelessness is a financial trap. Every tool payload returned, every conversational detour, and every clarification adds a compounding tax to the rest of that session.
The teams that build production AI agents that survive the next budget review won't necessarily be the ones running smaller models. They will be the teams that realize the most important part of an AI architecture isn't the model itself - it's the system that ensures the right context is delivered at the exact right moment.
This is what modus builds.
A context warehouse for data agents - automatically mined, intent-composed, securely delivered.