Est.

Context Windows, Token Costs, and Structured Data for Agents

Pre-calculated, governed datasets stop agent token costs from compounding.

· 10 min read · Updated
Cover illustration for “Context Windows, Token Costs, and Structured Data for Agents”
Agent Data Access Patterns · October 15, 2026 · 10 min read · 2,310 words

The cost of running AI agents on business data is not linear, it is compounding. Every turn resends the entire context window, and every data fetch adds raw payloads that persist long after they are useful. The structural answer is pre-calculated, governed datasets that give agents exactly the metrics they need, already resolved, through a single interface such as MCP.

Why every agent turn costs more than teams expect

Transformer inference re-reads the full context on every call. That means the cost of an agent's fifth turn includes not just the new input but the instructions, tool definitions, conversation history, and every payload fetched during the first four turns. Teams that model agent cost as turns multiplied by an average cost per turn will consistently underprice their systems. Early turns are cheap and late turns are expensive in ways an average conceals.

The mechanism compounds because agentic workloads consume far more tokens than single-turn chatbot interactions, and the gap is not marginal. MCP servers, APIs, and retrieval layers return raw payloads that accumulate in the context window. Many out-of-the-box agentic stacks lack a native mechanism to truncate stale tool outputs from the active context, though production-grade frameworks increasingly include compaction and observation-truncation features. The practical consequence is that each turn carries the full weight of every previous turn's data retrieval.

A concrete illustration of the gap appears when comparing an MCP-based agent against a standard CLI for the same task. MCP consumes many times more tokens per operation. The ratio depends on task type, but the direction is consistent and large. The issue is not the protocol's inefficiency. It is that structured tool interfaces bring schema definitions, metadata, and formatted responses into the context that a CLI invocation keeps outside it.

Diagram: Why Every Agent Turn Costs More Than the Last. Visualizes: Visualize how agent token costs compound across turns: each turn re-reads the full context window, which includes instructions, tool definitions, conversation history, AND every…

How data fetching inflates the context window faster than reasoning does

The dominant source of token bloat in business-data agents is not reasoning or conversation history. It is the raw payloads returned by data tools, which arrive unfiltered and stay in context long after their relevance has passed. A retrieval tool that returns a large raw payload on each call, across many calls in a multi-step workflow, accumulates a context burden that dwarfs the reasoning tokens.

Schema exploration compounds this. An agent that must discover which tables exist, what columns mean, and which field holds the authoritative version of a metric spends tokens on orientation before it does any useful work. A human analyst carries institutional memory: which reports are current, which fields nobody trusts, which source is authoritative for revenue. Agents lack that memory, so every query starts cold unless the infrastructure supplies the context up front.

Platforms like Dreambase prepare governed datasets with shared definitions baked in, so agents can access pre-modeled metrics with semantics resolved before reasoning begins. That construction avoids the cold-start orientation cost that otherwise consumes the first portion of every agent session. Without resolved semantic context, an agent picks a table and acts. It does not flag uncertainty the way a human analyst would. The wrong column used confidently is more expensive than the token cost of finding it.

The result is two compounding costs. The direct token cost of raw payloads grows with every retrieval call. The downstream cost of acting on ambiguous or incorrect data grows with every decision the agent makes from that payload. Both trace to the same root: data arriving as raw query results instead of resolved business context.

Why expanding the context window does not solve the cost problem

Larger context windows make it technically possible to paste more data into every call, but they do not reduce cost. They raise the ceiling on how expensive a single call can get. A million-token window means a million tokens of context can be supplied on every call, and every one of those tokens is billed on every turn. The window size determines the maximum invoice, not the efficiency.

Long-context windows suit one-off analyses where the full dataset is genuinely needed. They are not a cost strategy for high-volume agentic workloads where the same data shapes are queried repeatedly. Prompt caching cuts repeat costs substantially, and Anthropic, OpenAI, and Gemini all offer caching discounts. But caching only helps for content that does not change between turns. Raw query results pulled fresh each time do not benefit. A persistent layer of pre-modeled datasets that is served once and reused across many agent turns removes the need to re-fetch and re-cache the same underlying metrics on every call, which makes it a more durable cost strategy than relying on cache hits alone.

Context rot is a second reason larger windows are not a free lunch. Accuracy degrades well before a window's rated limit is reached, and relevant facts buried in the middle of a long context can cost significant accuracy points compared with facts placed at the edges. The practical ceiling is not the window size. It is the accuracy and cost of operating near that ceiling.

What pre-modeled, structured datasets actually give an agent

A pre-modeled dataset gives an agent a compact, semantically resolved payload: the exact metrics it needs, already calculated, with definitions baked in. The agent spends no tokens on schema exploration and receives no extraneous rows. The contrast with raw query results is stark. A raw SQL result may return thousands of rows and dozens of columns for a question whose answer is a single metric. A pre-calculated dataset returns the metric with its definition, its grain, and its freshness timestamp.

Semantic resolution occurs before the agent reasons. When MRR is defined once in the data layer and pre-calculated, the agent never has to choose between competing columns or guess at field meaning. The ambiguity that causes confident wrong answers is removed at the source. Infrastructure that hands the agent structured business context up front, including table definitions, ownership, freshness, and access rules, eliminates the cold-start orientation cost.

Dreambase operates as an MCP analytics server that surfaces governed, pre-calculated datasets from Supabase, ensuring agents query shaped, trusted data rather than raw tables. That cuts both the token cost per fetch and the risk of acting on uncertain definitions. The token savings are a byproduct of the right abstraction: an agent that receives a governed, pre-calculated metric payload does not need to retrieve, filter, or aggregate raw rows inside the context window.

Pre-modeled data also makes caching effective. A governed Parquet dataset that is refreshed on a known schedule has large stable sections that can be prompt-cached, compounding the cost reduction. The dataset is stored once, served repeatedly, and refreshed on a cadence that aligns with business needs rather than agent whims.

Why governance must be built into the data layer, not layered on afterward

Agents that query production databases directly create risks that no application-layer policy can fully contain. Agents are continuous, they operate at machine speed, and they accumulate permissions over time in ways human-centric governance was never designed to manage. Four characteristics break traditional governance. AI agents are always on, unlike humans who log off. They operate at machine speed, faster than detective controls can catch. They lack semantic context, unable to distinguish data they should touch from data they technically can reach. And multi-agent interactions create data flows that violate compliance requirements even when each agent acted within its stated permissions.

The production database risk is not theoretical. A 2025 Replit coding agent incident resulted in an agent deleting a company database, cited in the agentic infrastructure research community as the archetype case for why agents must not have unmediated production access. Agents break the two assumptions data infrastructure was built for: pipelines, which are versioned, reviewed, and logged, and people, who have defined roles and audit trails. Agents are non-deterministic and traverse data at speeds no human can monitor in real time.

The answer is not a gateway bolted onto an existing system. Governance must live inside the access layer, enforcing permissions, masking rules, and query boundaries at the data level before the agent reasons, not after. Separate service accounts per agent specialization, explicit lifecycle management, and query-level runtime policy enforcement are the minimum components, not optional additions once an agent is already running. A governed, pre-modeled dataset solves both problems simultaneously: it limits what the agent can see and what it must retrieve in a single architectural decision.

How governed access to Supabase data works without direct database credentials

MCP gives agents structured, permissioned access to pre-approved datasets and metrics through a single interface, without requiring agents to hold production database credentials or compose arbitrary queries. MCP servers act as connectors between AI agents and data sources. They can provide structured access, though permissioned enforcement of pre-approved metrics, reports, or fields depends on server implementation and external governance layers, not the MCP protocol itself.

The governance the data layer provides and the interface MCP provides are complementary. MCP is the steering wheel. The governed data layer is the road the agent is allowed to drive on. The July 28, 2026 MCP specification introduced a stateless protocol core, transforming MCP from a bidirectional stateful protocol into a request/response stateless protocol, one of the most highly-requested developer features. A remote MCP server that previously required sticky sessions and a shared session store can now run behind a plain round-robin load balancer, which improves reliability and scalability for production deployments.

The stateless architecture matters for pre-modeled data delivery. Agents can call an MCP endpoint for a governed dataset on any turn without the session state that previously created reliability bottlenecks. The important caveat is that MCP is a connective standard, not a governance standard. Governance depends on how each implementation enforces it, not on the protocol itself. An MCP server that exposes raw production tables is no safer than a direct database connection. What matters is not whether a team uses MCP but what is behind the MCP server. Governed, pre-modeled datasets deliver token efficiency and safety guarantees. Raw table access through MCP delivers neither.

What this architecture looks like for a Supabase team running agents today

Supabase teams face a specific version of the agent data problem. Supabase ships its own MCP server, so agents can read logs, query data, and modify schema from the same interface. That combination demands explicit guardrails that do not come configured by default. Supabase released supabase/agent-skills, a collection of 30 rules across 8 categories to help AI coding agents write correct, performant Postgres code. The categories cover query performance, connection management, Security & RLS, schema design, concurrency & locking, data access patterns, monitoring & diagnostics, and advanced features. The rules address common mistakes seen across hundreds of thousands of Postgres projects, including missing indexes, RLS bypasses, and connection pool exhaustion.

The agent-skills framing captures the principle well. The MCP server is the steering wheel, and the rules are the driving lessons. An agent with MCP access can execute any query, but an agent operating under these constraints will warn before creating an index that locks a table and structure queries to avoid performance problems. Supabase's analytics ceiling is the Postgres ceiling. It handles application analytics and millions of rows of event data well with proper indexes, but columnar analytical workloads at larger scale require a separate analytical layer. That gap is exactly where agent token costs are highest, because agents querying raw transactional tables retrieve far more data than they need.

For RAG and AI features, pgvector inside Postgres keeps embeddings beside the rows they describe, allows joins against user permissions and tenant scopes, and stays inside RLS policies. Supabase ships pgvector with HNSW index support out of the box, making it a natural fit for teams already on the platform. Supabase has also introduced Analytics Buckets built on Apache Iceberg, allowing large datasets to be offloaded from Postgres into queryable analytical storage. That is useful for time-travel queries and keeping the transactional database lean. The practical implication holds even on Supabase: agents should not query raw production tables for business metrics. The right pattern is a governed analytical layer that pre-calculates metrics, exposes them via a single MCP endpoint, and keeps agents entirely off the transactional database.

The single metric definition as the foundation agents and humans share

The deepest cost of agents querying unmodeled data is not the token bill. It is that different agents, and different humans, arrive at different numbers for the same metric, and no one can tell which is correct. If MRR means booked subscriptions in one dashboard and recognized revenue in another, the dashboard software is not the failure point. The organization never agreed on the definition, and automation makes the disagreement faster to distribute, not easier to resolve. Automating a broken metric just makes the broken metric easier to distribute. Report automation is a delivery mechanism, not a source of truth.

A pre-modeled, governed dataset with a single metric definition solves the agent token problem and the metric consistency problem at once. The agent receives the right number, calculated the same way every time, without spending tokens to find or validate it. This shared definition is more valuable than any dashboard feature, because it is the precondition for both human stakeholders and AI agents acting on the same facts. The alternative is a team where the agent's numbers and the founder's numbers diverge silently.

The practical framework for founders and operators is to organize metrics into Growth, Retention, Revenue, and Efficiency buckets, each calculated on a defined cadence from a single governed source. Then expose that governed source to agents via MCP, so the agent's answer and the board deck tell the same story. Dreambase's design, pre-calculated metrics pushed to where people work and exposed to agents through a single MCP server, is the architecture this argument has been pointing toward: not a patchwork of tools, but one governed data layer serving both humans and agents from the same definitions.

Sources

  1. Agentic Data Environments
  2. The 2026-07-28 MCP Specification Release Candidate
  3. Verifiable Agentic Infrastructure: Proof-Derived Authorization for Sovereign AI Systems
  4. The Importance of Out-of-Band Metadata for Safe Autonomous Agents: The Redpanda Agentic Data Plane

More in Agent Data Access Patterns