On this page
Context Engineering: Why Your AI Bill Is 90% Waste
Most enterprise AI spend is wasted on redundant input tokens. Context engineering restructures what models see to boost accuracy and cut costs by up to 94%.
Shopify’s engineering team made a discovery that should change how every team thinks about AI spending. When they restructured the context their agents received — without touching the prompts — accuracy jumped from 71% to 93%. When they did the opposite, improving prompts while leaving context alone, accuracy barely moved from 71% to 74%. That 22-point gap is the entire case for a discipline that most teams haven’t heard of yet: context engineering.
Here’s the uncomfortable truth behind it. Approximately 90% of a typical enterprise AI bill comes from input tokens — the files, search results, and background context you send to the model before it generates a single word of output. Only 10% is the actual response. Teams obsess over model tier and output pricing while bleeding money on redundant input they never needed to send. Context engineering is the practice of designing everything a language model sees before it generates a response, including system instructions, conversation history, retrieved documents, tool definitions, and memory from past sessions, per the emerging definition. It’s not prompt tweaking. It’s infrastructure.
The Prompt Engineering Ceiling and Why It Broke
Prompt engineering worked when AI was a single question-and-answer pair. You’d iterate on phrasing, add few-shot examples, specify output format, and get better results. That era ended when teams started building agents — systems that take actions over time, maintain state, call tools, and make decisions with real consequences.
A prompt is static. Context in an agent is dynamic. It grows on every turn as the model reads files, calls tools, and accumulates history. You’re not authoring a string anymore; you’re managing a budget that fills up on its own. Anthropic formalised the term context engineering in September 2025, defining it as finding “the smallest possible set of high-signal tokens that maximise the likelihood of some desired outcome,” per Professional Developer. The framing is deliberately economical — it’s about signal density, not volume.
The mental model that makes this click: treat context like RAM. The model is the CPU, and its context window is working memory. Just as an operating system carefully curates what fits into limited RAM, context engineering decides what earns a place in the window on every single turn. You’re managing a scarce, shared resource under contention from many sources. That’s a systems engineering problem, not a writing exercise.
A 2026 State of Context Management Report found that 82% of IT and data leaders agree prompt engineering alone is no longer sufficient to power AI at scale, and 95% of data teams plan to invest in context engineering training during 2026. Gartner declared 2026 “the year of context” and predicts the discipline will become foundational for AI engineering teams within 18 months. The consensus is clear: the bottleneck moved from how you ask to what the model sees.
The Token Economics: Why Cheaper Models Don’t Save You
This is where most cost analyses go wrong. Teams assume that switching to a cheaper per-token model tier will reduce their AI bill. The data says otherwise.
The core insight is that input-token waste, not model pricing, is the primary cost driver. A typical query might send 45,000 tokens of context to a model when only 5,000 are actually relevant — what researchers at Ability.ai call the “pizza problem,” where you order one pizza but pay for ten, every single time. Implementing a local code index with intelligent search can cut token usage by 94% while maintaining 90% accuracy. That’s not a marginal optimization. It’s a structural rethink of what you feed the model.
The economics get worse at scale because context window costs are non-linear. Doubling context length can increase latency 4x while delivering diminishing quality returns beyond the relevance threshold, according to Transactional’s research. You’re paying more in time and money for worse results. The “lost in the middle” effect means models attend most reliably to information at the start and end of a long context, and least reliably to what’s buried in the middle. More context doesn’t add capability — it dilutes it.
Here’s the contrarian takeaway: feeding bloated context to a $1/M input model can cost more than running a premium model with surgical retrieval. If 90% of your bill is redundant input tokens, a 94% reduction in token volume matters far more than a 2x difference in per-token price. Enterprise AI is shifting focus from larger models to better context and controls, with Anthropic framing the challenge as context configuration rather than prompt engineering, per Noah Intelligence. Model-tier shopping is a distraction. Context pipeline engineering is the lever.
Four Techniques That Actually Cut Costs
Teams practicing context engineering achieve 60-80% token reduction versus naive “send everything” approaches, cutting API costs proportionally. The techniques that deliver these savings fall into four core operations, per Atlan’s guide:
- Write — Persist task state outside the live prompt. Instead of keeping the full conversation in the window, write key facts, plans, and decisions to an external store (a scratchpad, a todo file, a structured database) and pull them back only when needed. This keeps the active context lean without losing memory.
- Select — Decide which sources enter the window and when. Not every document, tool definition, or prior turn deserves space. Selective injection means retrieving only what’s relevant to the current step, not front-loading everything the agent might possibly need.
- Compress — Reduce context only after key facts are structured and safe to shrink. Compression without structure first destroys signal. Summarize, deduplicate, and trim history once you’ve extracted what matters.
- Isolate — Separate contexts when domains or agents collide. A research sub-agent’s intermediate work shouldn’t pollute the main agent’s reasoning. Isolation partitions context across sub-tasks so each operates in a clean window.
The order matters. Select and structure before you compress. Compress before you isolate. When none of these fix the failure, the real problem usually sits upstream in the source context itself — your data, your documentation, your knowledge graph — not in the window management.
The tradeoff is real, though. Aggressive context compression and selective injection cut 60-94% of token cost, but they require ongoing engineering time, infrastructure, and maintenance overhead. This isn’t a one-time setup. Context evolves with your codebase, your workflows, and your team. You’re building a pipeline, not flipping a switch.
The Contradiction at the Heart of Context Engineering
Here’s where the data tells two stories that don’t fully reconcile.
On one side, context engineering is proven to massively boost accuracy and cut costs. Shopify’s data shows a 22-point accuracy improvement. Transactional’s analysis of 200+ sources shows 60-80% token reduction. The evidence is overwhelming that restructuring context outperforms prompt optimization by an order of magnitude.
On the other side, Gartner forecasts that 40% of enterprise applications will be integrated with task-specific AI agents by end of 2026, and over 40% of those agentic AI projects will be cancelled by 2027 citing poor context management, escalating costs, and unclear value. The same discipline that promises transformation is also the most common failure mode.
The tension resolves when you look at what “poor context management” actually means in practice. It’s not that teams aren’t trying context engineering — it’s that they’re doing it badly. They’re building brittle context supply chains with silent price redirects (like the Grok 4.1 Fast slug that quietly redirected to higher pricing for two months), cross-session amnesia where agents forget everything between sessions, and bloated inputs that dilute attention. The discipline works when it’s treated as infrastructure. It fails when it’s treated as a prompt template you download once.
There’s a second contradiction worth naming. The industry is simultaneously celebrating million-token context windows (GPT-5.6’s 1.05M window, virtual context systems managing 100M tokens) and treating context as a scarce, finite budget requiring strict curation. Both are true. Large windows allow more raw data per call, but attention degrades over long sequences and latency scales non-linearly. The window is bigger, but the budget hasn’t changed — you just have more room to waste.
Tooling Landscape: Managed vs. Self-Hosted Context Layers
The tooling for context engineering is fragmenting into two camps: managed services that reduce operational burden at the cost of per-seat fees and vendor dependency, and self-hosted open-source tools that give full control with zero license cost but demand engineering time.
Here’s how the key options compare:
| Tool | Pricing | Key Features | Target Audience |
|---|---|---|---|
| Context7 MCP | Free tier available, Pro at $10/seat/mo | Version-specific library docs injection, use context7 prompt trigger, eliminates outdated API hallucinations | Developers working with fast-moving frameworks (Next.js, React, Prisma) |
| Virtual Context | Free $0/mo, Pro $19/mo, Team $99/mo | Virtual context windows (2M-100M tokens), conversation state management, topic-based compression, AGPL-3.0 self-hostable | Production agents needing cross-session memory without infrastructure burden |
| Local Code Index | — (self-hosted, open-source) | 94% token reduction, 90% accuracy retention, intelligent search over codebase | Teams with engineering bandwidth to build and maintain indexing infrastructure |
The pattern I’ve observed — what I’d call the Context Budgeting pattern — is that production AI spend and reliability in 2026 are dominated by the curation and persistence of input context across sessions and providers, not by model tier or prompt design. The tools that win are the ones that integrate transparently into existing workflows rather than demanding workflow rewrites.
Context7, for instance, is one of the most-installed MCP servers in 2026 because it requires zero workflow change — you add use context7 to any prompt and it pulls current, version-specific documentation into context. The main complaint is that the Pro plan at $10/seat/mo adds up for teams wanting it on every developer. Virtual Context takes a different approach: it manages conversation state outside the live prompt, compresses by topic, and pulls back only what matters. The Free tier gives you 2M tokens of virtual context for experimentation, Pro at $19/mo unlocks 10M tokens with unlimited requests, and Team at $99/mo provides 100M tokens with 5 seats and shared memory namespaces. Every plan includes the open-source core under AGPL-3.0, so you can self-host and keep full control.
The tradeoff is straightforward. Self-hosted open-source tooling gives you full control and zero license cost, but managed context services reduce ops burden at the price of per-seat fees and vendor dependency. Teams often start by self-hosting during evaluation, then move to managed products when they want faster rollout or less infrastructure work. If you’re dealing with MCP security risks or wrestling with how MCP actually works in a stateless world, the context layer you choose needs to account for those architectural constraints.
A Decision Framework for Your Team
The right approach depends on your team’s size, codebase maturity, and tolerance for workflow disruption. There’s no universal best tool — only the best tool for your specific constraints.
If you’re a solo developer or small team working with fast-moving frameworks, start with Context7’s free tier. The use context7 trigger is zero-friction, and the main risk is library coverage gaps for niche frameworks. You’ll get immediate value from version-specific documentation without building infrastructure.
If you’re a mid-market team running production agents with cross-session memory needs, Virtual Context’s Pro tier at $19/mo is the default. You get unlimited requests, a 10M token virtual window, and session analytics. Self-host the AGPL-3.0 core if you have the engineering bandwidth and want to avoid the subscription. The enterprise AI coding stack conversation starts here — context, not model tier, is what drives cost.
If you’re an enterprise with a large, aging codebase, the local index approach delivers the highest ROI — 94% token reduction is transformative at scale. But you need engineering investment in data connectors, pipelines, and governance layers. This is where context engineering becomes a discipline, not a tool install. The MCP vs. APIs distinction matters here too: if you’re exposing context through MCP, you need to understand the protocol’s limitations for agent tool discovery.
If you’re in a regulated environment, treat the context window as a budget, not a bucket. The Federal News Network guidance is direct: limiting data, tokens, and tools keeps AI applications lean, fast, and accurate. Too much “garbage” in your context window results in poisoning, distraction, confusion, and clashes among facts. Design context so agents pull only the precise data they need, rather than preloading everything they might need.
The Open Question
Gartner predicts context engineering will become a foundational skill within 18 months. They also predict 40% of agentic AI projects will be cancelled by 2027 due to poor context management. The same discipline is both the solution and the most common failure mode.
The question isn’t whether to invest in context engineering — the data is unambiguous on that. The question is whether your team has the engineering capacity to build and maintain the pipeline, or whether you need a managed service to absorb the operational burden. Either way, stop shopping for cheaper model tiers. Start auditing what’s actually in your context window. You’ll likely find that 90% of it shouldn’t be there.