Skip to main content

Cost Control for AI Agents: What I Learned from a Webinar I Missed

The agents do real work, and every run comes at a cost. Cost control for AI agents in Microsoft Foundry involves model selection, prompt caching, and three questions that need to be answered before the bill arrives.
Cost control for AI agents is the fly in the ointment. Feature image showing a portrait of Robin Wilde, Head of Sales and Marketing at Contica.

Everyone’s talking about agentic AI, and we’re currently helping several clients build agentic platforms. So here’s an article that’s about as fun as salty pretzels at a party: cost control for AI agents. Don’t forget about the cost—focus on impact and value. Otherwise, you’re in for a rude awakening.

A webinar that came at just the right time

Björn Larsson has already described our proposal for how an agentic platform can be built in Azure, with Microsoft Foundry at its core. That’s the fun part, and it’s incredibly cool to see agents start doing real work.

Right in the middle of all that, I received an invitation to a webinar from Anthropic and Microsoft: “Claude in Microsoft Foundry: Control the Cost, Prove the Value.” I signed up. Then I missed it. The follow-up email began with “We missed you.” I watched the recording afterward, and it put into words something I’d been thinking about.

On the very day I’m writing this—November 17, 2026—Microsoft announced that Azure AI Gateway is generally available. A coincidence? It sure felt like one. But when so many people are building agents at the same time, it’s only natural that the question of cost would come up in many places.

Why does an agentic platform cost money in a new way?

Striving for efficiency with agents is absolutely the right approach. After all, that’s why we’re building these platforms. Björn writes that agents in production are measured per run: quality, cost, and value. We’re happy to talk about quality, while cost and value often take a back seat.

An agent in a loop where the entire conversation is resent at each iteration, so that the data sent to the model grows from iteration 1 to iteration 40.
At each iteration of the loop, the entire conversation is resent. Schematic diagram based on the mechanics described in Anthropic's guide.

As integrators, we’re used to Azure resources that are billed on a pay-as-you-go basis. An agent operates in a loop, and each iteration of the loop is a new call to the model. Anthropic calls this a “turn,” and I’m translating it as “iteration.” With an agent, the number of iterations isn’t predetermined.

Anthropic explains what this means in its guide, “Optimizing for Cost and Intelligence”: the agent resends the entire conversation at each iteration. The guide’s own example is a task with 40 iterations, which sends its first iteration 40 times. Anthropic also reports that runs with the same settings varied in cost in their measurements. Thus, the same task does not necessarily cost the same amount each time. We have not measured how large the difference is on our customers’ platforms.

The webinar I missed was based on three questions that management will ask: Who uses Claude, how much does it cost, and what return does it provide? Replace “Claude” with any model you like, and these questions apply to the entire platform. I don’t have any customer examples to point to. These are my observations, now that more and more companies are building agentic capabilities into their operations.

Which model is best suited for which task?

There is no definitive answer as to which model is best suited for which task, and the answer changes when models are swapped out. In its guide, Anthropic recommends measuring the cost per completed task for your own workload and testing two to three levels of the “effort” setting on a sample of the traffic. Microsoft specifies in the documentation for Claude in Microsoft Foundry what each model is intended for.

I personally find this difficult, and I don’t think I’m alone. One pitfall is going overboard and choosing a more capable model than the task requires, at a cost that could have been lower. If I go the other way, I end up with a model that performs worse, resulting in having to redo the work. The worst part is when I don’t trust the result and end up doing the work myself anyway. That comes at a cost, too.

Image from the webinar "The AI Sweet Spot, Part 2," featuring the quote "Don't cut trees with atomic bombs" by Håkan Åkerblom.
Håkan Åkerblom in the webinar “The AI Sweet Spot, Part 2,” which we hosted together with DevScope on May 4, 2026.

Håkan Åkerblom, our AI Integration Expert, put it better in the webinar “The AI Sweet Spot Part 2,” which we hosted together with DevScope on May 4, 2026: “Don’t cut trees with atomic bombs.” The right model for the right task. There’s also a responsibility not to use more computing power than the task requires, but that’s a topic for another article.

There’s a third pitfall, and I recognize it from integration projects. When we were building with Logic Apps Consumption, we’d sit in meetings and discuss a polling interval to cut costs. The savings amounted to a couple of öre, and we’d blow through that in consulting fees before the meeting was even over. The same thing could happen here. It’s still worth gaining a basic understanding of which model suits which task. Or do what I do: ask the AI. Just double-check the answer against the vendor’s current list, because the AI doesn’t always know which models are available today.

This choice also needs to be reevaluated when models are replaced. Anthropic notes that old prompts often contain instructions written for older models, such as “verify twice,” and that a newer model follows them to the letter and performs extra verification steps.

How does prompt caching affect the cost?

The model isn’t the only control. One thing that caught my attention in the webinar is caching. Since an agent resends the entire conversation at each iteration, it’s possible to let the beginning of the request remain with the model, making the resend more efficient. According to Anthropic’s guide, this requires that the beginning be identical character by character, in the order of tools, system prompt, and messages. A timestamp at the top of the system prompt is enough to prevent a match. Put what’s stable first and what changes last, and make changes to the system prompt and tools between runs. Microsoft states that prompt caching is supported for Claude in Microsoft Foundry, with a lifespan of five minutes or one hour. Different rules apply to other models, and I haven’t covered those here.

What is Azure AI Gateway?

Azure AI Gateway is a managed service in Azure that sits between your apps and agents and the models and tools they call. Apps and agents call the gateway, which in turn calls the models and tools. For each call, the gateway verifies the caller, applies your rules, forwards the call to the appropriate model or tool, and records telemetry. Microsoft announced on November 17, 2026, that the service is generally available.

Azure AI Gateway, which connects users, apps, and AI agents on one side to models, MCP tools, and APIs on the other, serves as a cost-control layer for AI agents.
Azure AI Gateway sits between the caller and the called service. Image: Microsoft.

For anyone who has worked with API Management, this pattern is familiar. The service was previously a tier within Azure API Management and is now a standalone product. According to Microsoft’s announcement, it can be used on its own, alongside Microsoft Foundry, or with Agent 365, and it connects to models from multiple providers, including Anthropic and OpenAI. Since all traffic to the models goes through a single point, the platform team can monitor and control costs there.

Three Things to Have in Place for Cost Control in Microsoft Foundry

Björn's proposal sets up the platform with identities and budget alerts right from the start. That's a good start. Based on the webinar and the documentation, I see three questions you'll need to be able to answer before the number of agents grows.

Who bears the cost?

Claude in Microsoft Foundry is billed in Claude Consumption Units, and the cost is tied to the Foundry resource. In Cost Management, it can be broken down by model and by input, output, and cache. Microsoft also notes that allocation by Foundry project is not supported for Claude. How you allocate resources and set tags therefore determines whether the cost can be allocated by team or business unit. Incidentally, this applies to all resources in Azure, and anyone who has worked with FinOps will recognize this. It’s a fundamental architectural decision that belongs at the foundation, alongside identities.

Azure AI Gateway adds a layer on top. According to Microsoft, the gateway tracks tokens and estimated costs per user, team, app, agent, and provider.

What happens when the budget is reached?

A budget alert in Azure is triggered. To stop usage, you'll need to set up your own automation, according to Microsoft's guidance on costs in Foundry.

The announcement on November 17 will be exciting. According to Microsoft, Azure AI Gateway has budgets that stop new calls when the estimated cost reaches the limit, as well as limits on tokens and calls to ensure that one agent does not crowd out the others. Apps also call the model via an alias, so the model can be switched without changing the code. Reevaluating the model choice then becomes a matter of configuration.

Three caveats. The cost for the gateway is an estimate, so the invoice is still being reconciled in Cost Management. The integration that allows prompt agents in Foundry to go through the gateway is in preview. And the gateway has its own price above the free tier, with billing starting January 1, 2027. So the monitoring also costs money, which brings me back to the polling interval. We haven’t deployed Azure AI Gateway in production. What I’m writing about it is based on Microsoft’s blog post.

What is the cost measured against?

A cost per run doesn’t mean much on its own. In Björn’s proposal, the person in charge of the case decides what’s required for the result to be considered a success, and the current solution serves as the baseline before any changes are made. Put these three side by side: the cost of the run, what the owner defines as a success, and what the same work costs today. Then you’ll have an expectation against which to evaluate each run, and any deviation will be apparent before the invoice arrives.

Where do you start?

Start with what you already have. If your platform currently has a budget alert, find out who receives it and what that person is expected to do. Then choose an agent that’s already in use, and write down how much a run costs and what the owner considers a successful outcome. This doesn’t require any new tools.

The cold shower I mentioned at the beginning comes when the invoice is the first time anyone sees the cost. Cost control should be as natural as salted pretzels at a party. They should just be there.

We've outlined the process—from the first workshop to a fully operational platform—on the page about the agentic AI platform in Azure.

Which of the three questions can you answer today? I'd love to hear your answer.

Sources and Further Reading

Everything the article is based on, compiled for those of you who want to dig deeper.

From Contica

From Anthropic

From Microsoft

Share this post


Post author image.

Author: Robin Wilde

Head of Sales and Marketing

More posts to sink your teeth into

loading="lazy"

An agentic platform needs more than just a brain

Agents are being built everywhere right now, often one at a time and by a single person. As an architect, my question is a different one: what does it take for them to become part of the organization? Here is our proposal for a sustainable agentic platform—and why architecture alone isn’t enough.
loading="lazy"

Logic Apps CLI Released in Public Preview. Here's How to Try It Out, and Here's What We've Seen So Far

Microsoft has released the Logic Apps CLI as a public preview. A code agent can already write a workflow, but it guesses at connectors and settings. Now it can ask instead.
loading="lazy"

Logic Apps Automation: When AI Becomes a Team Sport

I've been thinking for a while about how Microsoft's new releases fit together. When Divya Swarnkar and Jennie Zhou demonstrated Logic Apps Automation right after the session on Microsoft Foundry, it became clearer. Here's what I understood.
loading="lazy"

Agentic integration, and four patterns I’m taking away

On the drive home from the Nordic Integration Summit, Ahmed and I talked about agentic AI every single minute. Two days later, he and Amanda Orrbeck demonstrated what agentic integration looks like in Microsoft Foundry. Three things really stuck with me.