Why Your Agent's Biggest Cost Isn't the Model
Every agent has a mechanism that decides what its model sees on each turn. In most production systems, that decision was made during prototyping — and never revisited. That's a problem, because context is often the single largest line item in an agent's operating budget, and it's also the one thing that can improve on its own.
The model stays as capable as the day you picked it. Instructions only change when someone rewrites them. But what an agent knows, can access, and remembers grows as it runs. Managing that growth is called context engineering, and it's the difference between an agent that gets cheaper over time and one that quietly bleeds your cloud budget.
The Two Costs Nobody Talks About
Cost #1 — The obvious one: A model has no memory. Every turn, its context window is rebuilt from scratch: instructions, tool descriptions, retrieved documents, conversation history. For a chatbot answering one question, that's fine. For an agent working across dozens of turns toward a single outcome, it's the dominant expense. Unnecessary content gets billed every single turn.
Cost #2 — The invisible one: More context does not mean better answers. A relevant fact buried in 40 pages is harder for the model to use. A bloated tool list makes the wrong call more likely. Every mistake triggers another turn — and another bill.
Here's what makes context engineering strategically attractive: most cost reductions involve a tradeoff. Cheaper model? Lower quality. Shorter instructions? Weaker answers. But removing unnecessary context lowers cost without touching quality. That's a rare alignment of CFO and engineering interests.

The Four Questions That Define Context Engineering
Context engineering answers one question per turn: what does this request need? — not what might it ever need? Four questions cover the entire discipline.
1. What should the agent know?
The naive approach: dump entire documents into the prompt. Easy to build, expensive to run.
The managed approach: a knowledge layer that decomposes queries into subqueries, searches sources in parallel, semantically reranks results, and returns only grounded passages with citations.
# Conceptual flow of a managed knowledge retrieval layer
# (Microsoft Foundry IQ style — pseudocode)
def retrieve_for_agent(user_query: str, caller_identity: str):
# 1. Decompose the query into focused subqueries
subqueries = decompose(user_query)
# 2. Fan out across connected sources in parallel
raw_results = parallel_search(
subqueries,
sources=["SharePoint", "OneLake", "Azure SQL", "Blob Storage"],
identity=caller_identity, # Entra ID passthrough
)
# 3. Semantically rerank and keep only grounded passages
ranked = semantic_rerank(raw_results)
passages = [r for r in ranked if r.is_grounded][:TOP_K]
# 4. Enforce sensitivity labels before returning
return filter_by_purview_labels(passages)
Two properties make this layer worth building once: a single knowledge base can serve many agents, and access control is enforced at retrieval time using the caller's identity. Agents only see what the caller is authorized to see.
2. What should the agent be able to reach?
Tool overhead is easy to miss. Adding a tool might take one line of code — but its full description occupies the prompt on every turn, needed or not.
A managed toolbox solves this by exposing a single MCP endpoint for built-in tools (web search, code interpreter, file search) plus custom MCP servers, OpenAPI specs, and A2A agents. More importantly, tool search flips the model's interface: instead of the full tool catalog, the model gets (a) a way to describe what it needs in plain language, and (b) a way to call whatever comes back.
The result: the tool-list cost stays flat no matter how large the toolbox grows. In internal benchmarking, this cut average input tokens by roughly 97% for large tool libraries.
3. How should the agent do the work?
Knowledge and tools cover what the agent finds and does. Neither covers how your organization expects it done — the escalation path, the review checklist, the compliance step.
That guidance usually lives in the agent's instructions, gets copy-pasted across multiple agents, and is sent on every request even when irrelevant.
Skills turn that guidance into named, reusable procedures stored centrally. The agent initially sees only each skill's name and short description; it loads the full instructions only when relevant. Update the skill once, and every agent using it follows the new procedure — no redeployment, no code change.
4. What should the agent remember?
Replaying entire conversations on every turn is expensive and wasteful. A proper memory layer separates three concerns:
- Session memory — the current conversation
- User memory — persistent preferences and facts across sessions
- Procedural memory — learned workflows and task-execution patterns
Procedural memory complements centrally managed skills: a skill defines the approved procedure, while procedural memory lets the agent learn from its own execution. In Microsoft's evaluations, enabling procedural memory produced roughly a 5% improvement on STATE-Bench and Tau-Bench.
For a related case study on how enterprise AI investments pay off in measurable ROI, see Azure Databricks Delivers 331% ROI in Under 6 Months.

Why This Becomes a System, Not a Feature
Any team can bolt on retrieval, tools, skills, and memory. The hard part is making them work together under one permission model and keeping them current as the organization changes.
Here's the practical checklist when evaluating a context-engineering stack:
| Capability | Naive Approach | Managed Approach | Cost Impact |
|---|---|---|---|
| Knowledge | Full documents in prompt | Semantic rerank + grounded passages | ↓ 34% retrieval tokens |
| Tools | Full catalog every turn | Tool search + flat cost model | ↓ ~97% input tokens (large libs) |
| Skills | Copy-paste into instructions | Central registry, lazy-loaded | Proportional to relevance |
| Memory | Replay full conversation | Session / User / Procedural split | Eliminates redundant history |
| Permissions | Post-hoc filtering | Enforced at retrieval time | Zero leakage risk |
Limitations and Warnings
- Benchmark numbers are internal. The 54% recall improvement, 34% token reduction, and 97% input-token savings come from Microsoft's own evaluations. Treat them as directional, not universal.
- Tool search adds latency. The model must describe what it wants before it can call it. For agents with very small tool sets, the round-trip may not pay for itself.
- Memory is a compliance surface. Procedural and user memory need retention policies, TTLs, and user-level isolation — otherwise you've quietly built a shadow data store.
- Skills require governance. A centrally managed skill that everyone depends on becomes critical infrastructure. Version it, test it, and have a rollback plan.
Where to Go Next
If you're building agents today, start with an audit — not a rewrite:
- Log what enters the context window on every turn for one week.
- Rank inputs by token cost × frequency. Retrieval almost always wins.
- Introduce tool search before you introduce more tools.
- Extract one repeated instruction block into a skill and measure.
- Add session memory first, user memory second, procedural memory last.
The bigger picture: context engineering isn't about shrinking prompts. It's about building agents that improve with use — where knowledge, tools, skills, and memory all get better over time without a rebuild. For a hardware-side view of the same economics, see our breakdown of Microsoft's Maia 200 AI inference accelerator.

The Takeaway
Context engineering is the rare optimization that improves cost and quality simultaneously. Most levers force a tradeoff; this one doesn't.
The teams that win with agents over the next two years won't be the ones with the biggest models. They'll be the ones who treat the context window as a managed resource — audited, measured, and continuously refined.
Start by looking at what enters the context window on every turn. In many cases, fixing the inputs beats swapping the model.
Further reading: The Economics of Agent Optimization — Context Engineering for Enterprise AI Agents.