Most teams that add a language model to a working business process start in the wrong place. They start with the prompt. The prompt matters, but it is the easiest part to change later. What is hard to change is where the model sits in the workflow, what it is allowed to touch, and what happens when it is wrong.
This piece is about that second set of decisions. It assumes you already have a process that works without AI, maybe slowly and by hand, and you want a model to take over one step of it: reading inbound emails, classifying support tickets, pulling fields out of supplier documents, drafting a reply for a person to approve.
Treat the model as an untrusted upstream service
A model call should be wrapped like any external API you don't control: typed input, typed output, a timeout, retries with limits, and a validator between its answer and your database. The model's output is data to check, never an instruction your system obeys directly.
In practice that means the model never writes to your tables. Your code does. The model returns a structured object, your code validates it against a schema, and only a valid object moves the workflow forward. Anything else goes to a queue a person looks at.
type InvoiceFields = {
supplier_vat: string;
invoice_number: string;
issued_on: string; // YYYY-MM-DD
total: number; // plain currency units
currency: "EUR" | "USD" | "GBP";
};
const result = await extractInvoiceFields(pdfText); // model call, structured output
const parsed = InvoiceSchema.safeParse(result);
if (!parsed.success) {
await sendToReview(docId, parsed.error.issues);
return;
}
await saveInvoice(docId, parsed.data);
Structured output modes in current model APIs make malformed JSON rare, but a well-formed answer can still be wrong. Schema validation catches the shape. You still need the next layer for meaning.
Check the answer against facts you already have
The cheapest accuracy gain comes from comparing the model's answer with data your system already holds. If the extracted supplier isn't in your supplier table, or line items don't add up to the total, the answer goes to review instead of into the books.
Most business workflows are full of these cross-checks, and they were usually done by the person who did the step by hand, often without writing them down:
- Does the VAT number match a known supplier?
- Do the line items sum to the total, within rounding?
- Is the date plausible, not in the future and not years old?
- Does the order number exist, and is it in a state where this email makes sense?
Write each one as a plain function. They are boring, fast and deterministic, which is exactly what you want sitting next to a probabilistic component. When we look at an AI request from a client, a surprising share of the value ends up in these checks rather than the model; sometimes the checks alone solve the problem, which is why we wrote up AI requests we solved with SQL, a rules table or search instead.
Make every step idempotent before you add retries
Model calls time out and get retried, so the step that consumes their output must be safe to run twice. Key each unit of work on a stable id, record that it was processed, and make the write a no-op the second time.
The old manual process rarely needed this, because a person doesn't accidentally process the same email twice in the same second. A queue worker with retries will. Use the inbound message id, the document hash or the ticket id as the idempotency key, and store it with the result. A unique constraint in the database is the simplest guard there is.
The same applies to anything the step triggers downstream. If extracting an invoice also notifies accounting, the notification needs its own key, or a retry sends it twice.
Keep the human path, and make it the default
Route anything the model is unsure about, anything that fails a check, and anything with real consequences to a review queue. Start with everything going through review, then widen the automatic path category by category as the error log earns it.
A sensible rollout looks like this:
1.Shadow mode. The model runs on every item, but people still do the work. You compare its answers with theirs.
Draft mode. The model's answer is prefilled, and a person approves or corrects it with one click. Corrections are logged.
Partial automation. Categories with a clean record skip review. Everything else still goes to a person.
Each stage gives you labelled data from your own process, which is worth more than any benchmark. It also tells you when to stop: some categories never get clean enough, and that is a fine outcome. They stay with people.
For anything that sends a message, moves money or deletes something, keep a person in the loop even when the model is right almost every time. The cost of the rare mistake is what matters there, not the average.
Log inputs, outputs and the decision, not just errors
Store the input the model saw, the raw output, the validated result, which checks passed, and who approved it. When a wrong answer reaches a customer, this is how you find out whether the prompt, the data or the review step failed.
Keep the prompt version alongside each record. Prompts change often, and without a version you can't tell whether last week's errors came from last week's prompt. Be deliberate about personal data in these logs: redact what you don't need, and set a retention period that matches the rest of your system.
Choose the model last
Once the contract, checks, idempotency and review path exist, the model is a replaceable part. You can compare providers or a local model on your own logged cases, and switch without touching the workflow around it.
That is the real benefit of building it this way round. The workflow stays yours, testable and explainable, and the model becomes one dependency among many. At Jaspero this is how we approach AI work in products that already run: the first week goes on the contract and the checks, not on the prompt.
Key takeaways
- Wrap the model like an untrusted external API: typed input and output, validation, timeouts.
- Cross-check answers against data you already hold before anything is written.
- Make the consuming step idempotent before adding retries.
- Roll out from shadow mode to drafts to partial automation, and keep people on high-stakes actions.
- Log enough to tell a prompt problem from a data problem, then pick the model on your own cases.
Filip Lauc is the CEO of Jaspero, a software development agency based in Osijek, Croatia. A full-stack JavaScript developer with over a decade of experience across Angular, Svelte, and Node.js, he leads Jaspero's work as a long-term embedded engineering partner for clients like GlycanAge, where his team has served as the dedicated engineering team for six years.
Top comments (0)