Language models sometimes produce statements that sound confident and are simply untrue. The common name for this is hallucination. In a chat window, a hallucination is an annoyance: the user reads a wrong answer and, with luck, notices. In an agent, the same mistake can turn into an action. The agent invents an order number, then updates the wrong order. It assumes a customer has paid, then releases the goods. The error stops being words on a screen and becomes something that happened.
Why models make things up
A language model is trained to produce text that fits. It is very good at producing the kind of answer that usually follows a question. It does not have a built-in sense of whether it actually knows something. When it lacks the facts, it can fill the gap with something plausible, and plausible is not the same as true.
Hallucinations are more likely in certain situations:
- When the question asks for specific details the model was never given, such as a reference number, a price or a date.
- When the instructions pressure it to always give an answer, never to say “I do not know”.
- When the source documents are long, unclear or contradict each other.
- When the task involves unusual names, local terms or languages the model has seen less of.
Models keep improving, but no current model is free of it. Any design that assumes the model will never invent something is a design that will eventually fail.
How acting changes the risk
Three things make hallucination more dangerous in an agent than in a chatbot.
The error compounds. An agent works in steps. If step two rests on an invented fact, steps three to ten build on it. By the end, the output may look reasonable and be entirely wrong.
Nobody reads the middle. In a chat, a person reads every answer. In an agent, the intermediate steps often happen out of sight. The invented fact may never be seen by anyone until the result arrives.
Actions are hard to undo. A wrong sentence can be corrected. A sent message, a posted payment or a cancelled delivery may not be reversible, and may reach a customer before anyone notices.
Consider a small online shop where an agent answers delivery questions on WhatsApp. A customer asks where their parcel is. The agent cannot find the tracking record, but instead of saying so, it replies that the parcel was delivered yesterday. The customer, upset, asks for a refund. That one invented sentence has now created a complaint, a refund request and a lost customer.
Designs that contain hallucination
The goal is not to eliminate hallucination, which is not yet possible, but to make sure an invented fact cannot quietly turn into an action.
- Look it up, never recall it. Facts that matter, such as balances, stock levels, order status and prices, should come from a tool call to your real system, not from the model’s memory. If the lookup fails, the agent says so.
- Check references exist. When the agent names an order, customer or invoice, code should confirm that record exists before any action is taken. An invented ID then fails at once.
- Make “I do not know” an allowed answer. Write it into the instructions and reward it in testing. An agent that escalates when unsure is far more useful than one that guesses.
- Require evidence. For answers drawn from documents, ask the agent to quote the passage it relied on. A person or a simple check can then confirm the quote is real.
- Put a person before irreversible steps. Anything that moves money, reaches a customer or cannot be undone should wait for approval, at least until the agent has a long record of getting it right.
Spotting it after the fact
Logs are the main defence here. If every step the agent takes is recorded, including what it looked up and what came back, a person can trace any strange result back to the moment it went wrong. Without logs, a hallucination looks exactly like a correct action.
Spot checks help too. Each week, pick a sample of completed tasks and verify the facts the agent used against the source systems. Pay extra attention to tasks where the agent did not call any lookup tool, since those are the ones most likely to rest on invented details.
Be honest about the limits of all this. These controls reduce risk; they do not remove it. An agent may still misread a document it did look up, or draw a wrong conclusion from correct facts. Tasks where a single error is very costly, and where no person can check the work, may simply not suit an agent yet.
A useful exercise is to list every fact your planned agent will need and mark, for each one, where it will come from. Any fact marked “the model will know” is a place where hallucination can get in, and a place to add a lookup instead.