Your Function Call Was Free. This One Isn't.
Software Architecture Insights
December 1, 2026
You called that function a thousand times in a loop and never thought about it. Now the same call goes to an AI model. It takes a couple of seconds, and it sends you a bill. In this episode, Lee goes past his article "Your Function Call Was Free. This One Isn't.
Lee Atchison
This episode is brought to you by the Software Architecture Insights newsletter. Practical thinking on architecture, cloud scale and technical leadership every Tuesday morning. And it's free. Sign up at softwarearchitectureinsights.com/join.
Hello and welcome to Software Architecture Insights, your go-to resource for empowering software architects and aspiring professionals with the knowledge and tools they require to navigate the complex landscape of modern software design.
Think about the last function you wrote. You culled it a thousand times in the loop. You never thought twice about it. Why would you? It ran in microseconds and it cost nothing.
Now, change one thing. That function sends a request to an AI model, and each call takes a couple seconds, and each call sends you a bill.
Your loop just became a budget decision. In September, I wrote an article called Your Function Call Was Free, This One Isn't. It's part of my series on AI native architecture. Today, I want to go past the article into the places that bites hardest. Here's the idea in case you missed it. The original article is linked in the show notes. For most of our careers, calling a function has been free, fast and free. Then distributed systems came along, and a call over the network wasn't free anymore. It could be slow, it could fail, and we had to design our systems around that fact.
AI inference is the next version of that. Every call to a model costs real money and takes real time. So you can't treat it like a function call. It has to be part of the design.
That's the second of the four properties I use to define an AI native system. I call it inference economics. The article used an example. I'll keep it short. Picture a support assistant that handles 50,000 customer conversations a month. Each conversation makes six model calls. One to classify the question, one to find the right documents, a few to draft the answer, and then one to verify the results. That's 300,000 model calls a month. Now say every one of those calls goes to the biggest, most expensive model you have. Not because anyone decided that model was needed, just because that's the model the prototype used. Classifying a question into one of 12 categories doesn't need your most expensive model. Writing a careful answer to an angry customer, well, that might.
Which model handles which step is a design decision? The article called that model routing, and if nobody makes that decision on purpose, the prototype makes it for you. Here's what the article didn't go into, and it's where I'm seeing the biggest surprises now. Agents. The support assistant makes six calls per conversation. You can count them. You can multiply. You can predict the bill. An agent is different. You give it a goal, and it decides how many steps to take. It calls the model, looks at the result, and decides what to do next.
Sometimes, that action can take three calls. Sometimes, it takes 40 And sometimes, it gets stuck. It tries something, it fails, it tries again, and it keeps trying. In a normal program, a loop like that burns some amount of CPU. Somebody notices eventually. With an agent, every pass through the loop costs real dollars. A stock agent is a meter running with nobody watching it. So every agent needs limits, a maximum number of steps, a maximum spend per task, and a clear rule for what happens when it hits the limit. Does it stop? Does it hand the task to a person? Does it return its best answer so far? Those limits belong in the design of the application from the start, the same way a timeout is part of the design of a network call. If your agent has no step limit today, that's the first thing I'd fix. The second thing I change is the design review. Most teams have some kind of review before a big feature gets built. Someone asks about scale. Somebody asks about security. Someone asks about what happens when a dependency is down.
Add one more question. What does a single use of this feature cost? Not the monthly bill, one single use. One conversation, one document, one search.
Back in November, in the Level 2 episode, I talked about how to work out that number. The short version is you tag the calls, count what goes in and out, and divide. The point here is when you ask. Ask it before the feature is built as an estimate, then check the estimate once it's live. Something useful happens when you do that. The team starts designing for it. Somebody asks whether a step can use a smaller model. Somebody asks whether the same question gets asked a lot, and whether the answer can be reused. That last idea is basic caching. The article made a point about it. I want to repeat here. With normal caching, you match on the exact request. With AI, two people ask the same question in different words. So you match on meaning instead of the exact text.
Read the other 4 minutes of this episode here.
$15 gets you this episode and 99 more. Credits never expire. After checkout, one link brings you back here to read it.
Not what you expected? Full refund within 14 days.
Thousands of transcripts fetched by people building searchable podcast archives
Fetch transcripts with code
The same credits work from a script or an AI agent. The demo key returns a sample episode in full, no card needed:
curl -H "x-api-key: pt_demo" \
https://spoken.md/transcripts/1000651996090Markdown with the speakers named, for your notes, your knowledge base, or anything that makes HTTP calls.
From $0.10 per transcript. No subscription. Credits never expire. Prices exclude VAT, added at checkout for EU customers. Not what you expected? Email us within 14 days with 20 or fewer credits used and we refund the pack in full.
Using your own key:
curl -H "x-api-key: YOUR_KEY" \
https://spoken.md/transcripts/1000805040899