Context Window Data Quality and Its Effect on Agent Output
Agent failures start upstream, so govern the data before tuning the window.

What an agent produces is a direct function of what enters its context window. The instinct to fix agent failures by enlarging that window, or by aggressively trimming it at runtime, misdiagnoses the problem. The durable fix is not window management but data governance: ensuring that information surfaces to agents pre-modeled, semantically grounded, and free of the stale definitions and schema drift that corrupt reasoning. The question is not how many tokens the agent can hold, but whether the tokens it holds are the right ones.
Why the context window is the wrong place to look when agents fail
When an agent produces a confidently wrong answer, the reflexive response is to give it more room. The reasoning seems sound: if the model lost track of something, a larger window will let it keep more in view. The bigger-window reflex costs more, but the technical case against it is stronger still.
Context degradation does not wait for the window to fill. The Zylos AI research from 2026, cited in Atlan's guide, found that degradation begins at roughly half of nominal window capacity. Million-token windows shift where the degradation occurs, not whether it occurs.
The practitioners who study this problem most carefully have converged on a definition that puts selection at the center. The Anthropic Applied AI Team, in its canonical definition published September 29, 2025, described context engineering as "the set of strategies for curating and maintaining the optimal set of tokens during LLM inference." Andrej Karpathy's widely-cited definition from June 25, 2025 makes the same distinction in different language: "the delicate art and science of filling the context window with just the right information for the next step." Both definitions frame the problem as curation, not capacity. The window is a selection problem, and whatever fails inside it usually failed at the point of selection.
The five ways bad context actually breaks agent reasoning
Context does not degrade uniformly. It breaks through five distinct failure modes, each with a different cause and a different fix, and understanding them separately is what makes the upstream argument actionable. Redis's 2026 guide names and distinguishes all five. Length alone degrades performance.
Context confusion arises when irrelevant tools and documents clutter the window, causing the model to pick the wrong tool or blend unrelated sources. Context clash happens when contradictory information lands in the same window and the model arbitrarily picks one source or hallucinates a synthesis of both. Poisoning, distraction, confusion, and clash accumulate into this broader degradation over time.
For data agents specifically, Atlan's 2026 guide identifies semantic conflict as the most structurally damaging form of context rot. The Zylos AI research finding cited by Atlan, that a large majority of enterprise AI failures trace to context drift and memory loss rather than raw model limitations, points directly at this mechanism. Crucially, Atlan's guide is explicit: no amount of prompt engineering fixes semantic conflict. These problems exist upstream of the agent, in the data governance layer.
The attention geometry makes the damage worse. Bad tokens do not merely occupy space. They actively interfere with good ones. A stale glossary definition sitting in the window is not inert. It competes for attention against the correct information, and the model has no inherent way to know which source deserves the weight.
What runtime token management can and cannot fix
Runtime context management techniques are necessary for production agents. They can decide which tokens stay in the window, but they cannot determine whether those tokens are correct, and that distinction is where most agent failures actually live. Atlan's 2026 guide names the four runtime levers: selective injection, which classifies query intent first and then retrieves only matching context products. Active pruning, which removes tool output fields once they have been used. Compression, which summarizes older steps as the window nears a threshold. And hierarchical memory, which keeps lightweight references in-window and pulls full content only when needed.
These techniques deliver real value. The playbook maps each failure mode to a primary runtime remediation: write controls, selection filters, compression gates, and isolation. Multi-agent architecture, routing subtasks to isolated subagents with condensed handoff summaries, is itself a context isolation strategy rather than merely a capability pattern.
But every runtime technique trades something away. Its effectiveness depends entirely on the quality of what reaches the window in the first place. Runtime management is the last line of defense, not the first.
Why the fix has to start before the agent queries anything
The only durable fix for context quality is ensuring that data arrives at the agent pre-modeled, semantically grounded, and freshness-stamped, so the window fills with signal from the first token rather than spending its capacity on discovery work. Atlan's 2026 guide frames the contrast directly. Governed context delivery produces freshness-stamped metadata, policy-enforced permissioning, a single versioned source of truth, and versioned context products.
Pre-modeling changes the nature of what fills the window. Instead of raw schema exploration, query retries, and verbose JSON payloads, the agent receives a signal-dense payload: a named metric with a locked definition, a freshness timestamp, and permission confirmation already resolved. A query like "what does revenue_recognized_q4 mean in Q4 reporting?" maps to the specific glossary entry, schema definition, and lineage record for that field, not the entire data dictionary. This is upstream curation making runtime management easier, not replacing it.
Context engineering is fundamentally a curation problem, not a capacity problem. Selecting the right information matters more than fitting more information. Dreambase applies this principle at the data layer. Instead of exposing agents to raw production schemas and hoping compression handles the noise, it serves pre-modeled datasets that contain only the semantically correct, definitionally governed context agents actually need to reason reliably.
The semantic bypass risk is the failure mode this addresses. If it gets semantic context without query access, it cannot answer. Governed pre-modeling resolves both sides simultaneously. This is structurally analogous to the single-source-of-truth problem at the organizational level: one engineer's SUM(revenue) is another's SUM(amount_captured), and the agent has no way to adjudicate without an upstream authority.
Why agents must never touch production databases directly
Giving an agent direct production database access is not just a security risk. Create purpose-specific database users with minimal required permissions. Enforce PII redaction and resource filtering at the gateway layer.
The Redpanda Agentic Data Plane model formalizes this architecture. An MCP Gateway enforces tool-level policies, and both the MCP Gateway and the AI Gateway integrate with enterprise identity providers to propagate per-agent, per-user authorization context without exposing it to the agent. The lakeFS branching model adds data isolation: a branch is an isolated working environment containing all the same data at zero additional storage cost, and anything the agent modifies stays on its branch while the main branch remains unaffected until an explicit, controlled merge.
For Supabase teams specifically, connection exhaustion is the first bottleneck at agent-scale traffic, not LLM rate limits. The cardinal rule applies with particular force in Supabase deployments: do not rely on the model to remember which rows a user may see. Put access rules where the data lives.
What MCP actually does for context quality, and what it does not
MCP standardizes how agents call tools and access governed resources, but it is an interface layer, not a data platform. Launched by Anthropic in late 2024, MCP has become the de facto connector standard between agents and governed data. The July 28, 2026 specification revision dropped session state for a stateless core, unlocking horizontal scaling and HTTP standard routing, which matters for analytics workloads that generate many short-lived tool calls across metadata, semantic definitions, query engines, and catalogs.
When configured correctly, MCP enforces a meaningful governance separation. Only pre-approved metrics, reports, or fields are ever exposed. The critical architectural point is that MCP does not replace the need for identity, governance, semantic grounding, query performance, lineage, cost controls, and auditability. MCP surfaces them. It does not create them.
The NSA flagged a systemic risk in a May 2026 report: MCP's "rapid proliferation has outpaced the development of its security model." A single MCP server exposing pre-modeled Parquet datasets queryable via DuckDB is an example of MCP used as designed. The interface surfaces governed context, agents never reach through it to production Postgres, and the semantic definitions are resolved before the agent ever makes a call. That architecture is the pattern the standard was built to enable, not a default the standard provides.
How pre-modeled metrics change what an agent can actually do
When metrics are pre-calculated, versioned, and semantically locked before the agent ever calls them, the class of reliable agent tasks expands from simple lookups to root-cause decomposition, proactive monitoring, and autonomous workflow triggers. The single-source-of-truth principle is not just a governance nicety. It is a context engineering requirement. Without it, the agent and the human analyst are reasoning from different numbers, and neither knows it.
The governance model for AI-generated dashboards makes this operational. Require a human review on the first version of any new dashboard. Treat the AI dashboard tool as a production LLM system with traces and evals, not as a convenient shortcut. McKinsey's finding, cited in the research, puts the stakes in scale: eight in ten companies cite data limitations, not model capability limits, as the roadblock to scaling agentic AI. Most organizations will hit this ceiling before they hit any model capability limit.
What Supabase teams need to do differently now that agents are in the loop
Supabase teams face a specific version of the context quality problem. Postgres is an excellent operational database and a capable analytics home, but without deliberate schema hygiene, Row Level Security enforcement, connection management, and a governed analytics layer on top, agents querying it directly will assemble unreliable context from the failure modes already described. Supabase exposes a standard PostgreSQL endpoint, meaning any agent with MCP access can execute any query. The protocol's openness is the risk surface, which makes the governance layer more important, not less.
The most common failure modes documented across Supabase projects at scale are missing indexes on foreign keys, queries that bypass RLS by accident, migrations that lock tables in production, connection pool exhaustion from poorly managed clients, and full table scans hidden behind ORMs. Supabase's Agent Skills for Postgres Best Practices, the supabase/agent-skills open-source repository, provides 30 rules across 8 categories covering query performance, connection management, Row Level Security, schema design, concurrency, and related areas. An agent equipped with these rules will warn before creating an index that locks a table, suggest RLS policies before insecure code ships, and structure queries to avoid performance problems.
For agent-scale traffic, connection exhaustion arrives before LLM rate limits. A production Supabase agent architecture puts Postgres with pgvector at the center as the single state and vector store, uses Supavisor for connection pooling, and routes slow work onto Supabase Queues rather than the synchronous request path. The analytics extension pattern treats Postgres as the analytical home rather than extracting from it: pre-modeled metrics live as governed Parquet datasets queryable via DuckDB, with no ETL, no schema changes, and no new infrastructure. Put RLS policies where the data lives, and expose only governed outputs to agents, not the tables themselves.
Does governance slow down a small team? The trade-off is inverted
The strongest objection to governed context infrastructure is that it requires a dedicated data team and significant upfront work. A five-person team cannot staff a data engineering function, and governance frameworks built for enterprises often require exactly that. The cost of one ungoverned agent run, discovery steps, wrong table selection, compounded errors, and human debugging, likely exceeds the cost of modeling that metric once.
The Jarmak 2026 monograph frames this as a system dependency chain: weaknesses in retrieval and state management can invalidate conclusions made downstream, and investing in the retrieval and state management layer is not overhead. It is what makes every downstream agent investment pay off.
The architecture exists for teams operating under exactly this constraint. No dedicated data team, no data warehouse, no ETL, no schema changes. A Supabase project extended into full analytics capability, with governed metrics exposed via MCP so agents and human teammates get trustworthy numbers from the same pre-modeled source. The teams that will be limited by data quality are not the teams that invested too early in governed context infrastructure. They are the teams that deferred it until agents were already in production and producing confidently wrong outputs at scale.


