← All thoughts

July 15, 2026

When to use an AI agent vs. a simple API call.

The most common mistake I see in AI-assisted architecture — reaching for an agent when a plain function would be faster, cheaper, and more reliable.

The most common architectural mistake I see right now isn't using AI too little. It's using an agent — a multi-step, autonomous, tool-calling LLM loop — for something that should have just been a function call. It's an easy mistake to make, because agents feel impressive and modern, and a plain API call feels like admitting you didn't use the fancy thing. But an agent is slower, more expensive, and non-deterministic by design, and none of that is free. You're trading reliability for flexibility, and that trade is only worth making when you actually need the flexibility.

The test I actually use

If you can write down the exact steps, in the exact order, with the inputs fully known ahead of time — that's a function. Write the function. "When a form is submitted, validate it, save it to the database, send a confirmation email" doesn't need an LLM anywhere in it. Wrapping that in an agent adds cost and unpredictability for zero benefit.

An agent earns its cost when the task requires judgment that genuinely varies with the input — when you can't fully specify the steps in advance because the right steps depend on what you're looking at. "Read this inbound support message, figure out what it's actually about, and draft an appropriate response" is a real agent use case: the right response depends on content you can't predict, and rigid branching logic — a pile of if/else statements trying to anticipate every phrasing — gets brittle fast and is worse in every way than just letting a model read it and respond.

The pattern I use with clients

Default to plain code. Only reach for an agent when you can point to the specific judgment call that a deterministic function can't make — and even then, keep the agent's job as narrow as possible. A well-scoped agent that does one judgment-heavy thing well beats a sprawling one that's supposed to "handle everything," every time.

The GA4 reporting tool I wrote about recently is actually a good example of the boring end of this spectrum. Querying analytics data is entirely deterministic, so the MCP server itself is just plain functions — five of them, each doing one specific, predictable thing. The judgment — deciding what the numbers actually mean, what's worth flagging, what to suggest — is the part that's better left to the model asking the questions, not baked into the tool.

Why this matters more than it sounds like

Most of the "AI isn't reliable" complaints I hear trace back to this exact confusion: something that should have been a boring function got dressed up as an agent, and then people are surprised it behaves unpredictably. It was never a reliability problem with AI. It was a design problem — and it's usually an easy one to fix once you separate "does this need judgment" from "does this sound cooler with AI in the loop."

Have a prototype that needs to become a real product?

Fractional CTO, AI workflows, and agent teams — let's talk about what you're building.

Let's Talk