This weblog put up is the third of a four-part collection known as The Economics of Agent Optimization, which shares the methods, capabilities, and proof factors that can assist you optimize agent prices and run AI as a managed funding system on Microsoft Foundry. The primary put up set out the three selections that methods relaxation on. The second put up took the request at runtime. This put up takes the subsequent one: making every agent cheaper over time because it learns what works.
Each agent has a mechanism that determines what its mannequin sees on every flip. In lots of manufacturing methods, that alternative was set throughout prototyping and by no means revisited, though it usually drives the most important share of working value and contributes to disappointing solutions.
That is additionally the a part of an agent that may enhance by itself. The mannequin stays as succesful as whenever you chosen it, and directions change solely when somebody rewrites them. However what an agent is aware of, can entry, and remembers, grows because it runs—making it the important thing to enhancing efficiency whereas reducing value over time. Managing that course of is known as context engineering.
Why the context window units what an agent prices
A mannequin has no reminiscence of its personal. On every flip, its context window provides every little thing it may possibly use: directions, accessible instruments, retrieved paperwork, and dialog historical past. When the flip ends, that context disappears and should be despatched once more on the subsequent one.
That value is manageable for a chatbot answering one query. For an agent working throughout many turns towards one consequence, it’s usually the most important expense. As a result of the context window is paid for each flip, pointless content material is billed repeatedly.
The much less seen value is high quality. Extra context doesn’t assure higher solutions: a related truth buried in 40 pages is more durable to make use of, and a protracted instrument checklist makes the improper alternative extra doubtless. Every mistake provides extra turns—and extra value—to get better.
That makes context price a pacesetter’s consideration. Most value reductions contain a tradeoff: a less expensive mannequin might cut back high quality, and shorter directions might weaken a solution. In contrast, eradicating pointless context can decrease prices with out decreasing high quality, making it a better optimization for groups to assist.
What context engineering means in follow
That’s what context engineering does: it decides what enters the context window on every flip, so the agent will get what this request wants moderately than every little thing it’d ever want. As a one-time alternative, it’s a design resolution. Practiced repeatedly, it’s how an agent improves, as a result of each flip reveals what it truly used. 4 questions cowl the work, and groups normally take them on this order.
What ought to the agent know?
Many groups start with broad searches that insert total paperwork into the immediate. This method is simple to construct however pricey to run, and it forces the mannequin to search out the one related element amid every little thing else.
Foundry IQ replaces that with a managed information layer. A information base factors at sources throughout Work IQ, Cloth IQ, Net IQ, Microsoft Azure Blob Storage, SharePoint, OneLake, and Azure SQL. When an agent submits a question, Foundry IQ decomposes it into subqueries, searches linked sources in parallel, semantically reranks the outcomes, and returns grounded passages with citations. This narrows what enters the mannequin’s context to essentially the most related proof whereas preserving traceability to the supply.
Two options make this information layer reusable throughout brokers and governable at scale. A single information base can serve a number of brokers. Listed sources can refresh incrementally on a configured indexer schedule, whereas distant sources are queried on demand. At question time, Foundry IQ can run below the caller’s Microsoft Entra id, synchronize access-control lists for supported sources, and honor Microsoft Purview sensitivity labels, so the agent retrieves solely content material the caller is permitted to entry.
Our inside evaluations confirmed that Foundry IQ information bases improved proof recall by as much as 54% on the BrowseComp-Plus benchmark whereas decreasing retrieval token prices by 34%. The positive aspects got here from agentic retrieval, semantic reranking, improved reply synthesis, and extra environment friendly token use.
What ought to the agent be capable of attain?
Device overhead is simple to overlook: including one might take a single line of code, however its full description occupies the immediate. Each instrument hooked up to an agent has that description despatched to the mannequin on each flip, wanted or not, and enterprise brokers choose up instruments rapidly as they hook up with extra methods.
Toolboxes in Foundry give an agent one managed Mannequin Context Protocol (MCP) endpoint for built-in instruments like net search, code interpreter, and file search alongside customized MCP servers, OpenAPI 3.0 and three.1 APIs, and A2A brokers. Foundry manages authentication, entry insurance policies, and gear variations in a single place, moderately than configuring every integration individually for each agent. As soon as a brand new toolbox model is examined and promoted, linked brokers can use it with out code modifications or redeployment.

Toolboxes set up your instruments. The instrument search functionality inside Toolbox is what stops you paying for all of them. As a substitute of the complete checklist, the mannequin will get two issues: a solution to describe what it wants in plain language, and a solution to name no matter comes again. The price of the instrument checklist stays flat, nonetheless giant the toolbox grows. In inside benchmarking towards a public, open-source tool-retrieval dataset, Toolboxes in Foundry lowered common input-token consumption round 97% for big instrument libraries—immediately reducing inference prices for purchasers constructing brokers.1
Foundry additionally notices which instruments every toolbox makes use of most and places these inside straightforward attain, so the frequent path will get sooner and cheaper the longer the agent runs. Accuracy improves alongside value, as a result of a brief, well-matched checklist means fewer improper calls and fewer turns spent recovering.
How ought to the agent do the work?
Data and instruments cowl what an agent can discover and do. Neither covers how your organization expects the work to be achieved: the escalation path a assist agent follows; the guidelines a code assessment applies. That steering normally lives within the agent’s directions. Consequently, the identical procedures could also be copied throughout a number of brokers and included in each request, even when they aren’t related.
A ability turns that steering right into a named, reusable process. Abilities are saved centrally in Foundry and made accessible to brokers by a toolbox. As a substitute of embedding a replica of the process in every agent, the toolbox references the centrally managed ability. When your group improves a process, you possibly can publish a brand new model and set it because the default. Each agent utilizing that ability can then observe the up to date process with out code modifications or redeployment. To reduce context utilization, the agent initially sees solely every ability’s identify and quick description. It hundreds the complete directions solely when the ability is related. This makes it sensible to supply a big library of detailed procedures with out including pointless content material to each interplay.
What ought to the agent keep in mind?
Brokers want continuity, however they don’t want to hold each element from each interplay. Repeatedly sending a complete dialog to the mannequin provides value and consumes context, even when only some particulars stay helpful.
Reminiscence in Foundry Agent Service helps brokers retain essential context with out replaying total conversations. It helps three varieties of reminiscence:
Session reminiscence for the present dialog.
Person reminiscence for preferences and details that persist throughout classes.
Procedural reminiscence for discovered workflows and job execution patterns.
This permits a returning buyer to select up the place they left off, whereas enabling an agent to persistently observe confirmed processes with out being re-instructed every time.
Collectively, these capabilities assist an agent proceed a buyer interplay, personalize future responses, and enhance how reliably it completes recurring duties. Procedural reminiscence enhances centrally managed abilities: a ability defines the group’s authorized process, whereas procedural reminiscence helps an agent study from its personal job execution. In Microsoft’s evaluations, enabling procedural reminiscence produced a couple of 5% enchancment on STATE-Bench and Tau-Bench. Organizations may also management reminiscence by user-level isolation, retention settings, and time-to-live insurance policies that decide what’s saved and when it expires.
Why context engineering turns into a system
Any group can assemble information retrieval, instruments, procedural steering, and reminiscence. The problem is making them work collectively, below one set of permissions, and protecting them present because the group modifications.
Foundry brings these items right into a single system. Data, instruments, abilities, and reminiscence might be managed by shared infrastructure moderately than separate merchandise, whereas permissions are enforced the place information is retrieved, so brokers inherit the entry controls already utilized to enterprise content material. Foundry IQ extends that mannequin throughout enterprise information, enterprise information, and organizational context, whereas remaining appropriate with frameworks comparable to Microsoft Agent Framework, LangGraph, GitHub Copilot SDK, and Claude Agent SDK.
The result’s that context improves with out requiring brokers to be rebuilt. Data bases refresh as supply methods change. Abilities evolve as insurance policies evolve. Reminiscence accumulates what issues about customers and profitable workflows. Device search adapts to the capabilities individuals truly use. Agent optimizer in Foundry Agent Service then closes the loop by analyzing agent habits and producing improved directions, abilities, instrument descriptions, and mannequin configurations.
That’s the bigger purpose of context engineering: not merely decreasing immediate dimension or retrieval prices, however creating brokers that enhance with use. When the information they draw from, the instruments they uncover, the procedures they observe, and the recollections they maintain all develop into higher over time, an agent can develop into each extra succesful and extra environment friendly with out beginning over.
Get began
When you’re constructing brokers immediately, begin by analyzing what enters the context window on each flip. Take a look at the paperwork being retrieved, the instruments being uncovered, the directions being repeated, and the dialog historical past being carried ahead. In lots of instances, enhancing these inputs has a bigger affect on value and high quality than altering fashions.
Did you miss these posts in The Economics of Agent Optimization collection?
1 Command Line, Device search: Discovering the appropriate instrument on the proper time, July 29, 2026.

