# Deterministic tools with probabilistic interfaces are the future of AI

> Source: <https://weidev.nl/blog/deterministic-tools-with-probabilistic-interfaces>
> Published: 2026-11-30 23:32:49+00:00

**Recommendation:** Move search out of the model into a deterministic tool gateway with caching, provider fallback and structured responses; DoorDash cut cost 98% and fixed Claude Sonnet 4's 78.1% instruction-ignoring rate.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

While scrolling HN I cam across a blog post from DoorDash with an interesting, title: [How DoorDash Reduced LLM Search Costs by 98% Without Losing Accuracy](https://careersatdoordash.com/blog/how-doordash-reduced-llm-search-costs-by-98-without-losing-accuracy/). Ninety-eight percent. Not by switching to a cheaper model, and not by some clever prompt. They did it by no longer letting the model do the work, but going back to boring deterministic software.

And they are not the only ones. Look around and you start seeing the same move everywhere. The big players are quietly converging on a pattern where the AI is the *interface*, not the *worker*. Ask questions, have conversations, but the work is all just regular software.

LLMs are amazing at one thing in particular: taking something fuzzy that a human said and turning it into something precise (most of the time). "How did revenue do last quarter in Europe?" becomes `metric=revenue, period=Q3, region=EU`. That translation step is where the magic is, and nothing else we have does it nearly as well if you are working with unstructured input.

What LLMs are *not* great at is doing the actual work afterwards. Fetching data, doing math, joining tables, looping over 10,000 rows. They can do it, sure, but every time you ask you pay per token, you wait, and you might get a slightly different answer than last time. And especially the price part is pushing people to a new pattern.

The pattern looks like this:

Same input to the tool, same output. Every time. Cheap, fast, testable, and you can actually explain to an auditor what happened. Let's look at a few places where this is happening. Just how Uncle Bob intended it.

Back to DoorDash. Their query understanding system needs web search to figure out what people are actually searching for (is "450 north" a restaurant or a brewery?). Originally they used the model provider's built-in search. One request goes in, one answer comes out, and everything in between is a black box.

They replaced that with their own search gateway that the model calls as a tool. The gateway handles caching, picks a search provider, falls back to another one if it times out, and logs what everything costs. The model just asks the question.

The results on their production workload: accuracy went from 93.4% to 93.9%, and the search cost went from $7.90 to $0.11 per thousand queries. With a warm cache, 99.4% of queries never even hit a search provider.

But my favorite finding in that post is a side note. With the built-in search turned on, Claude Sonnet 4 ignored an explicit "answer only, no explanation" instruction **78.1%** of the time, happily starting with "Based on the search results…". Great for a chat window, terrible when the next step in your pipeline expects `Yes` or `No`. Moving search into a tool with a structured response mostly fixed that. So a deterministic tool didn't just make it cheaper, it made the model behave better.

Coding agents went through the same thing. Boris Cherny, who created Claude Code, said on the [Latent Space podcast](https://www.latent.space/) that an early version indexed codebases with embeddings, the classic RAG setup. Then they tried just letting the model use `grep` and read files, and it "outperformed everything, by a lot". The oldest search tool on your machine beat the blazingly fast modern vector database.

Text-to-SQL is the dream demo. Ask a question in plain English, the AI writes SQL, you get a number. The problem is that it gives you a *plausible* number. If it joins the wrong table or averages line items instead of orders, nothing actually breaks but you just get a wrong number that looks like a right one.

A semantic layer turns this around. The business logic (what "revenue" means, how tables join, which edge cases to handle) is defined once in code. The model only picks the metric and the dimensions, and a compiler generates the SQL deterministically.

dbt [benchmarked this](https://docs.getdbt.com/blog/semantic-layer-vs-text-to-sql-2026) earlier this year. On the same data, text-to-SQL scored 84–90% while the semantic layer scored 98–100%. Or as they put it, the semantic layer "can't produce correct-looking numbers that are subtly different across runs."

AtScale [ran something similar](https://www.atscale.com/blog/semantic-layer-text-to-sql-accuracy) with seven models and found something I think is even more interesting. Switching between models moved accuracy by at most 17.6 points. Adding the semantic layer improved *every* model by 20 to 31 points. Building the right tool for the job mattered more than "who" was doing the job.

And Fivetran [found](https://www.fivetran.com/blog/what-a-dbt-project-is-worth-to-an-agent) that Haiku, a small and cheap model, working through a semantic layer matched the accuracy of Fable writing raw SQL. At 1/13th of the cost per answer. Again, hammer meets nail.

The classic way agents use tools is one call at a time. Call a tool, get the result back into the context, think, call the next tool, and so on. That means every intermediate result travels through the model, and you pay for it in tokens every single time.

Anthropic wrote about [an alternative](https://www.anthropic.com/engineering/code-execution-with-mcp) in their original MCP announcement post: let the model write a small program that calls the tools, and run that program in a sandbox. The intermediate data stays in the sandbox, and only the final result goes back to the model. In their example, a workflow copying a meeting transcript from Google Drive into Salesforce went from 150,000 tokens to 2,000.

Cloudflare took the same idea with [Code Mode](https://blog.cloudflare.com/code-mode-mcp) and exposed their *entire* API, more than 2,500 endpoints, through two tools in about 1,000 tokens. Amazon [deployed it](https://aclanthology.org/2026.emnlp-industry.78.pdf) across 19 production agents and saw input tokens drop by 77%.

The model is still doing the smart part: understanding the task and writing the plan. The determinisitc part just still happens in normal code.

The logical end of this pattern is that some steps don't need a model at all.

Commure built an [AI claim summary](https://eng.commure.com/blog/dont-use-a-sledgehammer-to-crack-a-nut-lessons-from-tuning-an-llm-feature-for-speed-cost-and-quality) where the model called a tool to fetch the claim before writing the summary. But *every* summary needed that claim. So the model wasn't making a decision or doing anything smart. It was just a fancy endpoint for a static resource. Fetching the data in code first, plus switching to a smaller model, made the feature roughly 3x faster and 23x cheaper: from about $38.8K a month to $1.65K. Their rule of thumb: "Tool calling is valuable when the model has to decide what to look up. If the answer is always the same, do it in code."

Tetrate [puts it](https://tetrate.io/blog/not-everything-needs-llm) even more simply. Don't ask "can the LLM do this?", because the answer is almost always yes. Ask "does the LLM's judgment change the outcome?" If not, don't use it.

A couple of years ago, getting an LLM to do *anything* felt like a win. Now these things run in production (at scale) and different questions start to matter:

Of course this is not a silverbullet, unfortunately there is no such thing. When giving an LLM tools, their output can only be as good as the tool allows.

DoorDash found that for questions about recent events, the model provider's built-in search still won across every model they tested. dbt's semantic layer scored a flat 0% on questions that needed more joins than it supported. The tool can only answer what you built it to answer. But at least it says "I can't" instead of guessing, so that's something.

Also worth saying: a lot of these benchmarks come from companies selling the tool being benchmarked. So as with any software benchmark, take it with a grain of salt.

The pattern across all of these is the same. The model's job is shrinking to the part only it can do: understand what a human wants, pick the right tool, and explain the result. Everything in between is moving to software that does the same thing every time.

So if you are building something with AI, a simple rule goes a long way:

If it can be computed, compute it. If it needs to be interpreted, use the model.
