AI & Agents

What it takes to put an AI agent into a real workflow

Choosing the workflow, setting the measure, limiting permissions, testing on real cases, shadow running and handing over: a practical sequence.

Haadhi Irfan7 min read

Choose the workflow first.

An AI agent, in the sense used here, is a language model that can call tools: look up a record, read a document, draft a reply, update a field. Anthropic's engineering team draws a useful line in Building effective agents (opens in a new tab) between workflows, where models and tools follow predefined code paths, and agents, where the model directs its own steps. They recommend the simplest arrangement that works, and note that autonomy brings higher costs and the potential for compounding errors. Many business processes are best served by a fixed workflow with one or two model steps inside it, and that is worth checking before building anything more autonomous.

A good first workflow has five properties.

  • It happens often enough that minutes saved per case add up.
  • Its rules are mostly written down, even if the exceptions live in people's heads.
  • Its inputs arrive digitally: emails, PDFs, form submissions, support tickets, records in a CRM or ERP.
  • A person already checks the result, so there is a natural place for approval.
  • A mistake can be caught and reversed before it reaches a customer or a ledger.

Rare, high-stakes decisions with unwritten rules make poor first projects, however good the demo looks.

Define the measure before you build.

Agree with the workflow's owner what better means, in numbers you can collect today. Typical measures are the time from arrival to completion, the share of cases handled without rework, the error rate found when someone audits a sample, and the cost per case. Measure the current process over a representative period first. Without that baseline nobody can say whether the agent helped, and the project ends in a debate about impressions.

Set the acceptance line at the same time: the accuracy and coverage at which the owner would let the agent act on a category of cases without checking each one. Writing it down before the first demo stops the target moving later.

Give it as few tools and permissions as possible.

Every tool an agent holds is something it can get wrong or be tricked into misusing. The OWASP entry on excessive agency (opens in a new tab) names three root causes of damaging actions: excessive functionality, excessive permissions and excessive autonomy. Its entry on prompt injection (opens in a new tab) describes how instructions hidden in a website or file the model reads can alter its behaviour, which is exactly what an agent reading inbound email or supplier PDFs will meet.

  • Give the agent only the tools the workflow needs. A tool that runs arbitrary queries or sends arbitrary email is rarely necessary; one that looks up a single purchase order by number usually is enough.
  • Give each tool its own credentials, scoped to the records and actions it needs, and read-only wherever possible.
  • Prefer tools that create drafts and proposals over tools that commit changes.
  • Enforce limits in code, outside the model: amounts, record types, which fields may change. Instructions in a prompt can be overridden by what the model reads. Checks in code cannot.

Decide where people approve.

Human approval is a design decision with a cost. With too few checkpoints, a confident error reaches a customer. With too many, people approve without reading, which is worse than no checkpoint because it looks safe. OWASP recommends requiring user approval for high-impact actions, and Anthropic's guidance adds stopping conditions, such as a maximum number of steps, so an agent that is going in circles halts and asks for help.

Put approval on anything hard to reverse: payments, messages to customers, changes to master data, anything with legal effect. Make the approval screen show the evidence the agent used, the action it proposes and anything it was unsure of, so the reviewer can decide quickly and correct it when it is wrong. Record every correction. Corrections become the next round of test cases.

Build the evaluation set from real cases.

An evaluation set is a collection of past cases with the correct outcome recorded, run against the agent to score it. It should come from your own history, chosen by the people who do the work, and it should over-represent the awkward cases: the duplicate, the scanned page at an angle, the customer who writes in two languages, the case where the right answer is to escalate. A few dozen well-chosen cases are enough to start, and the set grows with every correction from production.

Score each case on what matters to the owner, which is usually more than one thing: was the decision right, was the extracted data right, did it escalate when it should have. Rerun the whole set on every change to a prompt, a tool or a model version, and count a provider's model update as a change.

An illustrative example: matching supplier invoices.

This example is illustrative and generic, not a client project. A distributor receives supplier invoices by email as PDFs. A finance clerk matches each one to its purchase order and goods receipt in the ERP, checks quantities and prices, and either queues it for payment or raises a query with the supplier.

  • Measure: the finance lead agrees three numbers from the last quarter, the median time from receipt to queued, the share of invoices queried, and the errors found in the monthly audit.
  • Tools: read one inbox folder, extract invoice fields from the PDF, look up a purchase order and its receipts by number, and create a draft match record. No tool can approve a payment or email a supplier.
  • Approval: the clerk sees each proposed match with the source fields highlighted, and accepts, edits or rejects it. Queries to suppliers are drafted by the agent and sent by the clerk.
  • Evaluation: a few hundred past invoices with their final outcomes, weighted towards partial deliveries, price changes and credit notes.
  • Rollout: shadow running first, then assisted matching on invoices that agree line for line with the order and receipt, then automatic queuing for that category once it clears the agreed line, with weekly audit samples.

Log everything, then run in shadow.

Log each run in full: the input, every tool call and its result, the model and prompt versions, the output, any confidence signals, and what the person did with it. Logs answer the question every owner eventually asks, which is why the agent did something, and they are where most improvements come from. Keep them under the same access rules as the data they contain.

Then run the agent in shadow. It processes real cases alongside the existing process and its output is compared, but nothing it produces is acted on. Shadow running surfaces the cases nobody thought to put in the evaluation set, and it measures the agent on today's traffic. When a category of cases clears the acceptance line in shadow, move that category to assisted mode, where a person approves each action, and only later, with sampling audits, to automatic. Autonomy widens one category at a time.

Plan for failure.

Agents fail in ordinary ways. A tool times out, a document will not parse, the model returns something that does not fit the expected format, or the input is unlike anything it was tested on. Each of these should route the case to a person with the reason attached. No case should disappear silently.

  • Validate the model's output against a schema before anything acts on it.
  • Set limits on steps, time and spend per case.
  • Keep a switch that returns the whole workflow to manual handling, and test that it works.
  • Alert on rates as well as single errors. A rise in escalations is often the first sign that an input format has changed upstream.

Hand over so the team can run it.

The agent is finished when the team that owns the workflow can run it without the builder. That means a named owner; a short runbook covering how to read the logs, pause the agent and add a case to the evaluation set; a record of the acceptance line and the current scores; and a regular review of audit samples. Train the people who approve its work on where it is reliable and where it tends to fail, using examples from the logs.

Wiser's AI & Agents practice builds agents in this order, starting from one workflow and the numbers that describe it today.

Sources

Talk to us

Want to talk it through?

Book a callA founder replies within one working day.