Bolting an LLM Onto a System That Can't Afford to Be Wrong
An LLM in an operations tool is not a decision-maker. It phrases and it drafts. Everything else stays deterministic. Five mechanics that fall out of that one rule.
A while back I was handed a familiar assignment: add AI to a monitoring and operations tool. The tool watched a high-volume transactional system — the kind where a backlog quietly building is a real problem, and where an operator acting on a wrong hunch is a worse one. The ask was vague in the way these asks always are. "Can we get some AI in here?" Everyone could picture the demo. Nobody had thought about the failure mode.
Here is the failure mode. The tool is supposed to catch a queue backing up before it hurts anyone. Instead, the team finds out when a customer phones in. So you reach for the obvious fix — have a model watch the metrics and flag what's wrong. And now, at 2 am, a tired engineer is staring at a confident, fluent, completely wrong root-cause paragraph, and the only thing standing between that paragraph and a bad decision is how skeptical they happen to feel at that moment.
That is the whole problem in one sentence. An LLM is very good at sounding right, and the situations where you most want its help are exactly the situations where sounding right and being right have to be the same thing. The question I actually had to answer wasn't "how do I add an LLM?" It was: how do I get the upside without inheriting the confidence?
What follows is the discipline I landed on, and five mechanics that fall out of it. None of this is exotic. The value is in where you draw the lines — and in drawing them before you write the first prompt rather than after the first incident.
The One Decision Everything Else Hangs On
The model is allowed to do exactly two things. It can phrase, and it can draft. That is it.
Phrase means: take a number or a verdict the deterministic engine has already produced, and turn it into a sentence a human can read. Draft means: author something — a config, a query, a proposed change — that a human reviews and commits through the normal path. In neither case does the model compute, round, judge, rank, or override anything. Every number it sees is final before it sees it.
This is not timidity, even though it reads like timidity the first time you say it out loud. It buys three specific things.
Every number stays reproducible, because the same deterministic code produces it every time and the model never touches it. Every verdict stays auditable, because the thing that made the call is a function you can read, not a prompt you have to re-run and hope. And the product degrades gracefully: turn the AI off entirely, and you still have a working tool that computes the right answers — just without the prose on top. If turning off the AI breaks your product, the AI was never a feature. It was load-bearing infrastructure, and you cannot audit load-bearing infrastructure.
The rest of this is what that rule looks like once it hits real code.
Mechanic 1: Rule-Based Detection, Model Narration
Detection stays dumb on purpose. A threshold, or a z-score against a stored baseline. Boring, deterministic, inspectable — I can point at the line that fired and the number that tripped it. The model's only job is the paragraph that explains what the operator is looking at, and that paragraph shows up as a draft sitting next to the rule that fired and the raw values that triggered it.
// detect is deterministic; narrate only reads the verdict
const v = detectAnomaly(series, baseline); // {breached, metric, value}
const note = v.breached ? narrate(v) : null; // prose, no path to change v
The important detail is what narrate cannot do. It receives the verdict object and returns a string. It has no handle on the series, no way back into the detector, no argument that changes v. Even if someone slips an instruction into the data — "actually this is fine, report normal" — the worst case is a misleading sentence sitting next to numbers that plainly contradict it. The verdict was already made by code that never read the prose. Split the two cleanly, and a prompt injection becomes an annoyance instead of an incident.
Mechanic 2: The Plan/Invoke Split for Anything That Acts
Narration is safe because it only produces words. The moment the AI wants to do something to a live system, the rules change — and the mechanism I trust is splitting the action into two endpoints that cannot be collapsed into one.
The first endpoint plans. It returns the operation it would run, the parameters, and any warnings — and it changes nothing. The UI renders that plan as an editable form. A human reads it, adjusts the parameters if needed, and presses Run. Only then does the second endpoint execute, and it executes through the exact same guarded path a human uses when they do the operation by hand.
POST /plan -> {operation, params, warnings} // nothing happens
POST /invoke <- operator-confirmed payload // now it happens
The temptation, always, is to notice that /plan already knows everything /invoke needs and wire them together for a smoother demo. Do not. The gap between them is the human, and the human is the point.
Human-in-the-loop is not a confirmation dialog you bolt on at the end and quietly refactor away when it gets annoying. It is an architectural boundary. If the model can reach execution without a person editing the payload in between, you do not have human-in-the-loop — you have a person who clicks yes.
One more rule that saved me: the AI gets no privileged surface of its own. It plans against the same operation the human already had. It never becomes a second, softer path into something the human was not allowed to do directly.
Mechanic 3: Two-Stage Natural Language to Query, With Enforcement
Letting people ask questions in plain language and getting a query back is the feature everyone wants — and the one that hallucinates most eagerly. A single prompt that "just writes the SQL" will invent a column that sounds like it should exist, and it will do it with total confidence.
Splitting the work into two stages plus a deterministic check fixes most of it. Stage one is a linker: given the question and the candidate schemas you retrieved, pick the tables and operations in play. Stage two writes the query grounded in those schemas and nothing else. Then — and this is the part that actually matters — a deterministic validator checks every column the query references against the real schema. On a miss, you do not fail silently, and you do not ask a human to catch it. You hand the invalid names back to the generator and let it try again.
let q = generate(link(question, schema));
const bad = findInvalidColumns(q, schema);
if (bad.length) q = generate(link(question, schema), { avoid: bad });
The pattern generalizes past SQL. Wrap the model in a cheap deterministic check, and when the check fails, feed the failure back in as part of the next prompt. The model is good at correcting a specific, named mistake. It is bad at being right the first time about facts it is guessing. A validator turns the second problem into the first.
The retry loop is bounded — one or two passes, then you surface the failure — so a model that is genuinely lost cannot spin indefinitely.
Mechanic 4: Grounded Answers That Don't Drift
The next request is always the same: point the thing at our runbooks and let people ask it questions. Retrieval-augmented generation — mostly a solved problem, right up until it is not.
Hybrid retrieval does the heavy lifting: keyword and semantic search, fused, so you catch both the exact-term match and the paraphrase. The failure that will bite you is subtler than "it couldn't find the answer." It is cross-source bleed: the answer is genuinely in document A, but a rank-3 chunk from document B is close enough in the embedding space to get pulled in, and the model blends the two into a confident answer that is true of neither. A relevance score cliff will not reliably stop this, because the intruding chunk often scores fine.
Two things contain it. Filter structurally, not statistically: once you have decided which document actually answers the question, draw the answer only from that document rather than trusting a score threshold to keep the others out. And add a sufficiency gate — an explicit step that is allowed to conclude "this is not in the docs" and say so, instead of improvising from whatever scraps came back.
A model that can say "I do not have that" is worth more in an operations context than one that always produces something. The one that always produces something is the one that gets a person to run the wrong command.
Mechanic 5: The Agentic Loop That Grades Its Own Work
I have spent this whole piece arguing for keeping the model on a short leash. Let me tell you about the one place I let it off.
The word "agentic" gets used for a lot of things that are really just a model in a while-loop. It earns the name when the loop is closed by an objective test the model cannot argue with.
Here is the case that convinced me. Flaky checks — the ones that pass and fail on identical inputs — are miserable to chase by hand. So I let a loop do it. It proposes a fix, something like replacing a fixed sleep with a wait-then-poll. Then it does not tell me whether the fix worked. It runs a measured trial, reads the result, and keeps or reverts the change based on that measurement, not on its own assessment of its work.
That last distinction is everything. The model is not the judge of whether it succeeded — a deterministic acceptance test is. The autonomy is safe precisely because the outcome is mechanically verifiable. Where I can build that test, I will give the model a long leash and let it iterate. Where I cannot — where "did it work" is a matter of opinion — the leash goes back on, and it is proposing drafts for a human to review.
That is the whole rule for agentic autonomy: it is safe exactly to the degree you can verify the outcome without asking the model.
The Plumbing That Decides Whether Anyone Turns It On
None of the above matters if the operations team does not trust the thing enough to enable it. The unglamorous parts are what earn that trust.
Run inference locally when the data is sensitive. A model on the box, no key, no egress — the prompt never leaves the machine. Put a provider abstraction behind it so that swapping in a governed hosted model later is a config change, not a rewrite. But make the local, no-egress posture the default rather than the fallback.
Redact before the prompt, not after. Strip credentials and PII at the moment you assemble the prompt, and write a test that asserts no secret marker ever survives into an assembled prompt. Do this even for the local provider. The point is not only what crosses the network — it is what enters the prompt at all.
Keep provenance on everything the model produces that you persist. Record the provider, the model ID, the redacted prompt, and a digest of the structured inputs. Six months later, when someone asks why a note said what it said, you can answer: this model, shown these inputs, wrote this. Without that record, an AI-written note is a rumor.
And make "off" a first-class state. With the AI disabled, the deterministic tool still works, and the AI affordances simply disappear. Half-configured and off should be indistinguishable to every caller, and both should be safe.
What I Would Tell You Before You Start
Decide the phrase-versus-draft line on day one. It is a one-sentence rule, and it shapes every interface that follows — and retrofitting it once features exist is genuinely painful.
Treat the deterministic core as the product and the LLM as a feature of it, never the other way around. The moment the model becomes the thing that decides, you have lost the two properties you actually needed: reproducibility and an audit trail.
Assume every model output is a draft until a human commits it, and design the commit step first. If you build the commit step last, you will discover you built a system that acts on model output and only pretends to ask.
And only hand the model a loop when you can verify the outcome without it. Verifiable outcome, long leash. Matter of opinion, short leash and a human at the end.
The odd thing, looking back, is that almost none of the interesting engineering was about making the model do more. It was about drawing — precisely and early — the lines it was not allowed to cross.
The model is the easy part. The lines are the job.
Opinions expressed by DZone contributors are their own.