AI drafts, code decides: stopping an LLM from inventing prices
A language model is very good at reading a messy WhatsApp chat and working out what the customer wants. It is not a safe place to decide what they pay.
At a Lagos manufacturing company, sales ran on WhatsApp. Quotes were typed by hand, and finance matched bank alerts to customers one by one. We built a quote-to-pay system where an AI agent reads the chat and drafts the quote. The interesting part is everything the agent is not allowed to do.
The risk
Ask a model to "prepare a quote" and it will happily produce one, with prices, discounts and a total. Some of those numbers will come from your catalogue. Some will be plausible guesses. A few will be products you don't sell. In a system that sends payment links, a confident guess is a financial error with your logo on it.
The split: structure from the model, money from code
The agent's job is narrowed to what language models are good at: understanding intent. It returns a structured draft, items from the catalogue by ID and the quantities the customer asked for, and nothing else.
// What the agent may return
type Draft = { lines: { sku: string; qty: number }[]; notes?: string };
function accept(draft: Draft, catalogue: Map<string, Item>): Draft {
for (const line of draft.lines) {
if (!catalogue.has(line.sku)) throw new Rejected(`unknown product ${line.sku}`);
if ("price" in line || "total" in line) throw new Rejected("drafts may not set money");
if (!Number.isInteger(line.qty) || line.qty <= 0) throw new Rejected("bad quantity");
}
return draft;
}
Prices, VAT and totals are then computed in code from the catalogue, in integer kobo, so there is nothing for the model to round or invent. A draft that tries to set a price, or names a product that isn't in the catalogue, is rejected outright rather than quietly corrected.
A person still approves
Every customer sits in exactly one of eight stages, from New chat to Sent to production. A drafted quote waits for finance to approve it before the quote and its payment link go out. The AI removes the typing; it doesn't remove the sign-off.
Why rejection beats correction
It is tempting to "fix" a bad draft automatically: drop the unknown product, overwrite the price. We don't, for two reasons:
- A rejected draft is visible. Someone sees it and handles it. A silently corrected one hides a misunderstanding about what the customer wanted.
- Rejections are measurable. If the rate climbs, the prompt or the catalogue needs attention, and you can see it in the numbers.
The general rule
Let the model propose what; let typed rules and computed results decide how much. We use the same split in our grounding guard, where the model may explain findings but may not state a figure the system didn't compute.
Adding an AI feature where mistakes cost money? Our applied AI practice builds it so the model drafts and your rules decide. Or book a free 30-minute call.