Architecture Pattern · Tool Decision
Code Chooses Tools, Not LLMs
Why deterministic tool calling beats agentic AI for money-critical decisions. Our refund system proves that code should decide which tools to call, not the model.
Architecture Pattern · Tool Decision
Why deterministic tool calling beats agentic AI for money-critical decisions. Our refund system proves that code should decide which tools to call, not the model.
The core question in AI system design isn't "should we use an LLM?" It's: "who decides which tools the system calls?"
In an agentic system, the LLM sees a set of available tools and decides which ones to call, in what order, with what arguments. In a deterministic system, code decides the tool sequence. The LLM never sees the tools.
Agentic: LLM sees tools → LLM decides which to call → execution follows
Deterministic: Code decides tool sequence → tools execute → no LLM in the decision loop
The agentic pitch is seductive for many workflows. Handles edge cases you didn't code. Reads messy natural language. Adapts to new situations. For triage, drafting, summarization—this is often right.
For refunds, we chose deterministic. Here's why and what we're learning.
A refund decision is binary and consequential: money leaves the business or it doesn't. What matters is delivery status, days since delivery, order amount, customer history. That's all structured data. No messy prose to interpret. And when it goes wrong, it's not "slightly worse UX." It's real money leaving the company:
So we're building it the boring way. Fixed sequence of data lookups. Deterministic eligibility check against policy. Hardcoded decision path. No model decides whether money moves. Ever.
In the agentic pattern, the LLM sees your tools and decides which ones to call. For a refund system, this means:
get_customer(), get_order(), get_delivery(), issue_refund(), send_email()The problem: on day 1, with one phrasing, the LLM calls tools in order A. On day 2, with slightly different context, it calls tools in order B. The decision is not reproducible. Not auditable. Not defensible to a regulator.
The agentic pattern: LLM sees available tools and decides which to call. Decision power is distributed across a system you can't fully audit.
We borrowed patterns from agent infrastructure, but removed the autonomy. We built a scoped tool gateway that:
This is defensive infrastructure, not AI autonomy. The gateway doesn't decide when to call tools—the code does. The LLM never talks to the gateway. The code talks to the gateway.
We initially named it SecureMCPGateway (implying Model Context Protocol compliance). It wasn't. It was just a hardcoded dispatcher with three allowed function names and no dynamic discovery.
We renamed it ScopedToolGateway. Clearer. Honest about what it does: enforce boundaries around tool access, not emulate an LLM framework.
The lesson: Adopt the infrastructure patterns that matter (audit logs, scope boundaries, access control). Reject the framework patterns that give LLMs autonomy they shouldn't have.
As this system grows, the natural place for an LLM is upstream:
All of that is advisory. A human or a deterministic rule still gates the money-moving step. The model is a helper that makes a human decision faster, not a replacement for it.
If you're building a money-critical workflow, here's the architecture that's working for us:
The system we built (deterministic automation with human approval):
Deterministic workflow with human approval: eligible refunds wait for support team review before issuance. Every decision and every approval is logged and auditable.
Request flow: code controls all tool decisions
Two gates, not one: code decides eligibility, a human decides approval. Neither gate is an LLM.
Security & compliance built in:
Support operations dashboard: every ticket, approval, and audit event tracked and reviewable.
For CTOs: A deterministic refund system is operationally simpler. You audit it once, test it end-to-end, then ship it with confidence. An LLM-based system requires continuous monitoring, hallucination detection, and a support team trained to reverse bad decisions. In production, simpler beats smarter.
For CEOs: The cost math is brutal. A single erroneous AI-issued refund can cost thousands. A run of bad decisions can trigger chargebacks, payment processor review, and account suspension. A compliance violation discovered in an audit can cost millions. A deterministic system removes that tail risk entirely. You know exactly what the system will do, and regulators know you're not gambling with customer money.
Risk breakdown:
Request processing: deterministic logic means every decision is auditable and repeatable.
Before reaching for an agent framework or a language model for a financial workflow, ask:
If your answer to the last one is "just more impressive," you're adding an attack surface and a failure mode for no gain. Deterministic code that's well-tested and auditable beats a model with judgment you can't fully verify-especially anywhere real money, real PII, or real irreversible actions are involved.
We'd rather ship the boring version that's provably correct than the exciting version that's probably fine.
This isn't a retrospective. It's a live project. We're building a customer support refund agent right now, documenting the architectural decisions as we discover them, and learning what actually works (and what doesn't) when deterministic automation meets real traffic.
Most teams building AI-powered systems face this decision: When should we use an LLM, and when should we use deterministic automation? The answer for money-critical workflows is almost always the same: deterministic wins. But getting there requires domain expertise: audit trail design, database constraints that enforce business rules, token-based data scoping, concurrency patterns, compliance integration.
If you're facing this choice, we can help:
Whether you're moving from manual to automated, or re-architecting from agentic AI to deterministic patterns, let's talk through the decision. We're documenting what we learn and happy to share it.
Join the Conversation