Series 1 of 4 · Agentic Stack · Level 2 · Topic 17

Context Economics

Harness Architecture
In This Note You Will Learn
  • 01. Why every token in the context window has a dollar value -- and how adding 1,000 tokens to every query costs $547K/year at enterprise scale.
  • 02. How model tiering (Haiku for routing, Sonnet for reasoning, Opus for high-stakes) cuts inference costs 60-70% without measurable quality loss for most queries.
  • 03. Where the diminishing returns curve lives -- the point where adding more context costs more than the quality improvement is worth.

The Story

A B2B customer intelligence platform processes 500,000 queries per day for 340 enterprise accounts. Sales teams ask about prospects, deal status, and competitive positioning. The product uses Claude Sonnet for everything -- every query, every intent, every complexity level.

The AI inference bill is $312,000 per month. Growing 15% month-over-month. At current trajectory, the annual run rate will hit $5.4M by Q4. The company's entire engineering budget for the AI product is $8M annually. Inference costs alone are consuming 67% of the product's budget, and the ratio is getting worse.

The PM maps the queries by complexity. 45% are simple lookups that a smaller model could handle. 40% are moderate reasoning tasks. 15% are complex multi-source analyses that genuinely need Sonnet's full capability. One model serves all three tiers. The platform pays Sonnet pricing for a query that asks "What's John's email?"

The Core Idea

Context economics is the discipline of budgeting tokens across CONTEXT layers, understanding cost curves across model tiers, and finding the point where more context costs more than it's worth. At enterprise scale, context engineering IS cost engineering.

Context economics treats the context window as a finite resource with a known dollar value per token -- through model tiering, per-layer token budgets, caching strategies, and diminishing-returns analysis.

-- The working definition

Think of it like a restaurant kitchen during a price spike on premium ingredients. A chef who uses wagyu beef for every dish -- burgers, stews, tartare -- will bankrupt the restaurant. Premium models for premium queries, efficient models for routine ones. The dish quality barely changes for the stew. The cost drops by 80%.

Fig 1. The Token Economy
Every Token Has a Price Tag
Sonnet-Tier Context Budget ~11,000 tokens / query
C
O
N
T
E
T
OUT
Constitution18%
4%
kNowledge40%
Tracks12%
6%
Output19%
40%
of your Sonnet spend lives in kNowledge. Retrieval is both your biggest quality lever and your biggest cost lever. Tightening retrieval from 5 chunks to 4 saves ~$17,600/month at this scale.

Every 1,000 tokens saved at 500K queries/day = $547K/year

Premium models for premium queries. Efficient models for routine ones. Same kitchen, different ingredients per dish.
Cost per query
Useful, but lies when responses cascade.
Cost per outcome
The denominator is everything. A $0.05 query with 3 follow-ups beats a $0.09 one-shot — only on the wrong metric.

Model tiering strategy. The single most impactful cost optimization is not sending every query to the same model. Haiku (or GPT-4o mini, Gemini Flash) handles intent classification, simple lookups, structured extraction -- 40-50% of enterprise queries. Sonnet handles multi-step reasoning and complex analysis -- 40-45%. Opus handles high-stakes decisions where the cost of a wrong answer far exceeds inference cost -- 5-10%.

The Klarna case study. Klarna reported that their AI assistant handled the equivalent of 700 full-time agents' work in its first month. The economics worked because of aggressive context optimization: efficient models for simple tasks, routing only complex disputes to more capable models, and caching frequent query patterns. The headline savings came not from model capability but from the economic architecture around it -- tiering, caching, and routing.

Where This Hits in Production

Cost attribution per tenant. In B2B products, the PM needs to know which tenants are the most expensive to serve. Cost attribution -- tagging every inference call with the tenant ID -- turns "our AI bill is $300K/month" into "Tenant A costs $42K/month for $180K ARR, while Tenant B costs $3K/month for $150K ARR." This data informs pricing and capacity planning.

Caching economics. Anthropic's prompt caching charges $3.75/M for the initial cache write but only $0.30/M for cache reads -- a 90% discount on cached tokens. For a product where the constitution and tool definitions are identical across queries for the same tenant, caching those 3,500 tokens saves 90% of their cost on every subsequent query.

Margin-aware product decisions. "Should we add conversation memory?" becomes "Adding memory increases average context by 1,500 tokens, which costs $547K/year at our volume -- does the quality improvement justify that?"

!

The Trap

Optimizing for cost per query instead of cost per outcome.

A team reduces their average context window from 18,000 to 11,000 tokens. Cost per query drops 38%. But complex queries now require 1.4 follow-ups on average (up from 0.3) because the first response is less complete.

The cost per resolved user need -- the metric that matters -- actually increased because the savings on initial queries were offset by the follow-up volume.

The fix: measure cost per outcome (resolved question, completed task), not cost per individual inference call. A $0.09 query that resolves in one turn is cheaper than a $0.05 query that needs three turns ($0.15 total).

In Practice: The Three Levers

Three targeted optimizations delivered $729K in annual savings for approximately three engineering weeks of work. 16x ROI in Year 1.

Fig 2. The Three Levers
$729K Saved. Three Weeks of Work.
The highest-ROI context engineering interventions
Model Tiering
Route 45% of queries to Haiku
$223K/mo
44% Reduction
Prompt Caching
Cache the Constitution prefix
90% discount
90% Cache Hit
Retrieval Tightening
Fewer, better documents
15-30% leaner
30% Leaner
$729K annual savings
Three engineering weeks. 16x ROI in Year 1.
Before: $511K/month After: $287K/month
$729,000 annual savings. Three engineering weeks. 16× ROI. The dashboard tells you exactly which lever to pull next.
↳ kNowledge = 40% of Sonnet spend. Highest cost leverage. Start retrieval tightening here. The dashboard doesn't just measure — it ranks the next-action items by impact.

Remember This

1. Every 1,000 tokens saved per query saves $547K/year at 500K queries/day on Sonnet pricing. Context economics is not abstract -- it's a line item that scales linearly with volume and can dominate product budgets within months.

2. Model tiering is the single highest-impact cost optimization. Routing 45% of queries to Haiku saves 60-70% on those queries with negligible quality loss -- because those queries never needed deep reasoning.

3. Optimize for cost per outcome, not cost per query. A cheaper query that requires three follow-ups costs more than an expensive query that resolves in one turn.

References

1. Anthropic API Pricing -- Anthropic

2. Prompt Caching -- Anthropic Documentation

3. Klarna AI Assistant -- Klarna Press Release

4. OpenAI API Pricing -- OpenAI

5. Context Engineering for AI Agents -- Anthropic Engineering Blog

Previous Topic Back to the Deep Dive