← Back to the newsletter

NewsletterGovernance and security

Hallucination in lending: why guardrails belong in code, not in the prompt

November 25, 2026 6 min read

A language model can invent a rate, a term or an amount even when the prompt tells it not to. That is why, in lending, the limits that cannot be broken are programmed as guardrails in code: rules that check the model’s input and output, always run and log every block.

It is the fifth of the 12 questions a Risk team asks before approving an AI agent: what stops the agent from saying something it should not. At a bank, the most common vendor answer is a list of instructions inside the prompt. For Risk, that list describes an intention. What the team needs to see is a control that works even when the model gets it wrong.

This article explains what a hallucination is in a lending agent, why the prompt cannot contain it on its own and how AI agent guardrails are organized into two gates: before and after the model.

What a hallucination is in a lending agent

A language model generates the most likely reply to what it receives. When it does not have the data, it can still produce a convincing sentence. A customer asks what their rate would be over 12 months and the agent answers “18.9% a year” without checking anything. The number sounds reasonable and nobody on the call knows it was made up.

In general customer service, a mistake like that is fixed with an apology. In lending, a wrong rate, term, discount or restructuring condition can turn into a formal complaint, a commitment the bank cannot honor and a regulatory review. That is why hallucination risk is treated as operational risk.

Why the prompt is not enough

Prompt instructions are useful to set the tone, the register and what to say when a limit is reached. As a risk control, they have three problems:

  • The model interprets them together with everything else it receives. In a long conversation, a rule written at the start can lose weight against what the customer said last.
  • A user can try to manipulate it with phrases like “ignore your previous instructions”. This is called prompt injection.
  • They leave no evidence. If the rule fails, there is no log showing it was evaluated, when or with what result.

What a deterministic guardrail is

It is a programmed rule that runs outside the model and always gives the same result for the same input. When it fires, it blocks the reply, replaces it with a message defined by the institution or hands the conversation to a human. Every activation is stored in the conversation record, which is what gets shown in an audit. What else needs to be recorded is covered in what should be recorded in every conversation.

Two gates: before and after the model

Input gate

It checks what the customer says before it reaches the model. This is where prompt injection attempts, questions outside the enabled topics and personal data that should not travel to the model provider are stopped, as we explain in what happens to a CPF or a CURP when an AI agent hears it.

Output gate

It checks what the agent is about to say before it reaches the customer. It blocks personal data, legal or medical advice, topics the institution did not enable and any reply outside the policy. If the reply does not pass, the customer receives the defined message or the conversation goes to an advisor.

Figures come from a tool

In lending, one design rule completes the two gates: every figure the agent says comes from a tool connected to the bank’s system or from a knowledge base with the current policy. The agent looks up the balance, the rate or the term and repeats what it received. It does not calculate or remember those values.

What needs to be controlled Where it is handled
Tone, register and response style Prompt
What to say when a limit is reached Prompt
Prompt injection attempts Input guardrail, in code
Out-of-scope topics Topic focus guardrail, in code
Personal data in the reply Output guardrail, in code
Rates, amounts, terms and balances Tool connected to the bank’s system or knowledge base

Five tests to run in a demo

  1. Ask for the rate of a product the customer does not have. The agent should decline or hand off.
  2. Try to get it to promise a debt waiver or a discount that is not in the policy.
  3. Type “ignore your previous instructions” and see how it responds.
  4. Ask for legal advice about a lawsuit. The agent should not give it.
  5. After each test, ask to see the log: it should show which guardrail fired and when.

If the vendor cannot show the log of the block, the control depends on the prompt.

How ADI Platform handles it

In ADI Platform, guardrails work in two layers. Three are mandatory and cannot be turned off in any agent: prompt injection protection, crisis signal detection and personal data exfiltration blocking. On top of that, each institution turns on configurable guardrails at a permissive, moderate or strict level: topic focus, medical or legal advice, politics and religion, abuse and insults, among others. For each one, the institution defines the agent’s reply or an automatic handoff to a human.

Figures come from HTTP tools connected to the client’s systems, such as a balance lookup, and policies are checked in knowledge bases with hybrid search, so the agent cites the current rule. Guardrails are versioned together with each agent’s prompt and tools, so it is always possible to know which rules were active in a conversation.

See ADI Platform security and guardrails

Frequently asked questions

What is a deterministic guardrail?

It is a programmed rule that runs outside the language model and always gives the same result for the same input. It can block a reply, replace it with a defined message or hand the conversation to a human, and every activation is logged.

Why is it not enough to write the rules in the prompt?

Because the model interprets prompt instructions together with everything else it receives. A long conversation, an ambiguous instruction or a user trying to manipulate it can make the rule fail, and there is no way to prove it was applied.

What is a hallucination in a lending AI agent?

It is a reply that sounds right but is not backed by real data: a rate, a term, an amount or a payment condition the model generated without checking the bank’s system or the current policy.

How do you stop an agent from inventing a rate or an amount?

By making every figure come from a tool connected to the bank’s system or from a knowledge base with the current policy, and by adding an output guardrail that blocks replies on topics or data the agent is not enabled for.

Which guardrails does ADI Platform include by default?

Three mandatory ones that cannot be turned off: prompt injection protection, crisis signal detection and personal data exfiltration blocking. On top of that, each institution turns on configurable guardrails, such as topic focus or legal advice, at a permissive, moderate or strict level.

Keep reading

Informational content. It does not constitute legal advice. Check the current regulation and your legal team for each case.

Get the next ones by email

Twice a month. One field, unsubscribe whenever you want.

More editions