Published Nov 26, 2026

Most AI features should be one call and a validator, not an agent

By Kevin Champlin

The first version of our layoff classifier in the AI Tax project looked impressive in a demo. You gave it a company name, and an agent went off to search press releases, fetch WARN filings, read two or three articles, decide which sources mattered, and return a record with headcount, effective date, and whether AI was cited as a reason. It worked about 90% of the time. The other 10% was where the trouble lived. One run would spend forty seconds re-searching the same company. Another would decide a subsidiary's numbers were the parent's. A third would politely return a date in 2019 for an event that happened last month, and nothing in the system would flag it, because the output looked like valid JSON.

I spent a weekend staring at traces before I admitted the obvious: the agent loop was not the product. The record was the product. Everything the loop did was an elaborate way of getting three fields and a source URL, and the loop had no contract for what "correct" meant.

What the loop was actually costing us

Before the rewrite, I pulled a week of runs. The numbers were not close to what the demo suggested:

  • Average of 11.2 tool calls per record
  • p95 latency of 48 seconds per record
  • About $0.34 per record in model spend, most of it re-reading context the agent had already seen
  • A 9% rate of records that were structurally valid but semantically wrong, which I only found by spot-checking

The worst part was not cost. It was that the agent's failures were quiet. A tool timeout did not throw an exception that reached a human. It produced a slightly different answer, and the loop kept going.

The single structured call

The replacement is almost boring. We fetch the candidate documents ourselves, with ordinary HTTP and a cache keyed on the canonical URL plus a content hash. We pass the cleaned text, typically one to three documents trimmed to a few thousand tokens, to the model in a single request. The request forces a JSON response against a schema, with explicit enums and nullable fields:

{ "company": string, "headcount_affected": integer|null, "effective_date": "YYYY-MM-DD"|null, "ai_cited": boolean, "source_url": string, "confidence": "high"|"medium"|"low" }

Two decisions matter more than the rest. First, nulls are allowed, and the prompt says so explicitly. Models under pressure to fill fields will invent plausible numbers. Giving them a legal way to say "not stated" cut our fabricated-headcount rate more than any prompt wording did. Second, the schema is versioned in the repo. When we changed the enum for event type, the validator rejected old-version output instead of quietly mixing them.

The call is one job on a Laravel queue. Retries are bounded at two, and each attempt writes its request hash, token counts, and raw response to a table. When something goes wrong at 2 a.m., I can see exactly what the model was given.

The validator is where the reliability lives

The validator is plain PHP. No framework magic, no second model judging the first. It checks things a person would check:

  • The effective date is not in the future and not before the company's first filing in our records
  • The headcount is within a sane range for the company's known size, and a headcount above total employees from the last filing is a hard reject
  • The source URL's domain appears in the set of documents we actually fetched, which kills most hallucinated citations on sight
  • If ai_cited is true, the quoted phrase must appear verbatim in the source text, checked with a normalized substring match
  • Low-confidence records and any validator failure go to a review queue instead of the published table

That last check is the one that changed my mind about the whole architecture. A verbatim-quote check is trivially cheap and catches the exact failure the agent loop produced most often: a confident claim with no support in the text the model was given.

The numbers after the change

Over the following month, with the same source corpus:

  • Model calls per record dropped from 11.2 to 1
  • p95 latency dropped from 48 seconds to about 4 seconds
  • Cost per record dropped from roughly $0.34 to $0.06, a bit under one-fifth, once we counted the fetch cache and the smaller prompts
  • About 6% of outputs failed validation and went to the review queue, which I consider the system working
  • Records that reached the published table and were later found wrong dropped below 1% in spot checks

The 6% matters. The agent version had no equivalent number, because it had no concept of "this output is unacceptable." It just had outputs.

Where the loop still earns its keep

I am not arguing that agents are useless. I have shipped them. In a Fortune 500 apparel brand's catalog migration, a multi-step reconciliation task genuinely needed the model to decide what to look up next, because the next query depended on the last answer. That is a real case for a loop.

The test I now apply is simple. Can you write down, before the model runs, every piece of information it might need? If yes, the model does not need to choose tools; it needs a well-specified input and a validator on the output. If no, and the path genuinely branches on what the model discovers, then you have earned an agent, along with a step budget, a hard kill switch, and per-run spend caps. We learned those guardrails the hard way on the AI Showcase, where an unbounded loop burned through a day's budget in one bad afternoon.

Most of the AI features I see in client codebases fall on the first side of that line. A product description generator, a support-ticket tagger, a WooCommerce catalog cleanup pass: these are one call, one schema, one validator. The engineering effort belongs in the schema and the checks, not in the orchestration.

Boring is not the same as simple. Boring means the failure modes are enumerable, the costs are predictable, and a new engineer can read the whole path in ten minutes. That is the standard I want for anything that touches a published record.

If your AI feature needs a dozen tool calls to produce a three-field record, the model is not the thing you need to make smarter. Give it a contract, and put your effort into the validator that enforces it.

Free Tool

See exactly what AI costs — across every provider.

MyTokenTracker is a free, multi-provider intelligence platform with live pricing across 100+ models. Compare Claude, GPT-4o, Gemini, and more side-by-side — built for developers evaluating models, teams tracking API spend, and founders building AI-native products who want to stay cost-aware before it becomes a line item worth explaining.