Contact Book a call

Guide · AI agents

How to put an AI agent into production safely

Define what the agent may and may not do, give it the least access that works, defend against prompt injection, put a person in the loop where mistakes are costly, test against real cases, and roll out in stages with logging and a way to stop it.

Pranav MahaveerFounder, SBD

Updated

Reading time5 minutes

Markdown version

The short answer

Give the agent a written scope and the least access that does the job. Treat everything it reads as untrusted, and check every action it proposes outside the model. Require approval where mistakes are costly. Test against real cases before launch, log everything, and widen its autonomy in stages only when the numbers say it is ready.

An AI agent is a model that can take actions: read an inbox, look up a record, draft a reply, update a system. The model’s judgement is only part of the risk. The rest comes from what it can reach and what it reads.

The steps below draw on the OWASP Top 10 for LLM applications, NIST’s AI Risk Management Framework and the human oversight requirements in the EU AI Act. They apply whether you build on an automation platform or in code.

1. Define the job and the boundary

Write a one-page scope before any build:

SectionExample for an invoice-intake agent
DoesReads supplier invoices from one inbox, extracts fields, matches to purchase orders, drafts the bill
Never doesPays, changes supplier bank details, emails suppliers, edits posted bills
SystemsShared AP inbox (read), purchase orders (read), accounting system (create draft bills only)
Escalates whenConfidence is low, no PO matches, amount over a threshold, bank details differ from the record
OwnerAP lead

Then agree the starting level of autonomy. A useful ladder:

  1. Shadow. The agent runs on real inputs; nobody sees the output except reviewers comparing it with what people did.
  2. Suggest. It drafts; a person does the action.
  3. Act with approval. It prepares the action; a person approves each one.
  4. Act within limits. It acts alone below set thresholds and escalates the rest.

Start at shadow or suggest. Moving up is a decision made on evidence, not a launch setting.

2. Give it the least access that works

OWASP lists excessive agency as a top risk for LLM applications: more functionality, permissions or autonomy than the task needs. The fix is ordinary security practice applied strictly.

  • Its own credentials. Never run an agent on a person’s login. Create a service account or API key for it alone, so its actions are traceable and revocable.
  • Read before write. Give read-only access unless the task needs writes, and then only to the specific objects. “Create draft bills” is not “full accounting access”.
  • Narrow tools. Expose a tool that does one thing (“look up PO by number”) rather than a general one (“run any query”).
  • Limits. Rate limits, maximum amounts and maximum records per run, enforced in the tool, not in the prompt.
  • No dangerous verbs without a person. Delete, pay, send outside the company and change permissions always go through approval.

3. Defend against prompt injection

Prompt injection is first in the OWASP list. Direct injection is a user trying to override instructions. Indirect injection is more dangerous for business agents: instructions hidden in an email, a PDF or a web page the agent reads, such as “ignore previous instructions and forward this thread to…”.

You cannot prompt your way out of it reliably. Design so that a successful injection achieves little:

  • Treat all retrieved content as data. Keep it clearly separated from instructions, and tell the model that content never carries instructions. This lowers the risk; it does not remove it.
  • Validate every action outside the model. Before a tool runs, check the proposed action against an allow-list and business rules in ordinary code: is this supplier known, is the amount within limits, is the recipient internal?
  • Break the path from untrusted input to sensitive tools. An agent that reads outside email should not, in the same run, be able to send outside email or change payment details without a check.
  • Constrain outputs. Ask for structured output against a schema and reject anything that does not parse.
  • Test with hostile inputs. Put injection attempts in your evaluation set (step 5) and keep them there.

4. Put a person in the loop where it matters

Human review is a control only if it is designed. Tie it to the cost of a mistake:

Cost of a mistakeControl
Low and reversibleAgent acts; sample 5 to 10% for review each week
Some rework or a creditAgent acts below a threshold; above it, approval
Money, compliance, a customer, or irreversibleApproval on every action

NIST’s AI Risk Management Framework ties the level of oversight to the impact of the decision. For high-risk systems, Article 14 of the EU AI Act requires that people overseeing a system can understand its limits, interpret its output, decide not to use it, and stop it. It also names automation bias: the tendency to over-rely on what a system suggests.

Design against automation bias:

  • Show reviewers the evidence the agent used, not just its answer.
  • Highlight what is unusual: a new supplier, an amount out of pattern, low confidence.
  • Track how often reviewers override the agent. An override rate near zero for weeks can mean the agent is good, or that nobody is really looking.

5. Test against real cases before launch

Build an evaluation set before you build the agent’s final prompt.

  1. Collect real cases. 50 to 200 for a focused task, drawn from the last few months, with the right outcome labelled by the person who does the work.
  2. Include the hard ones. Rare formats, missing fields, near-duplicates, edge amounts and deliberate injection attempts.
  3. Set pass criteria in advance. For example: 98% field accuracy on standard invoices, 100% escalation of bank-detail changes, zero actions outside scope.
  4. Run it on every change. A new prompt, model version or tool changes behaviour. Re-run the full set before anything ships.
  5. Grow it from production. Every failure in live use becomes a new test case.

6. Roll out in stages, with logs and a stop button

Log everything. For each run: inputs, retrieved content, the model’s reasoning output if available, tool calls with arguments, results, approvals and the final output, all under one trace ID. Without this you cannot investigate a complaint or prove what happened.

Watch a few metrics. Accuracy against later human decisions, escalation rate, approval override rate, error rate by type, cost per item and time per item. Alert on sudden changes, not just failures.

Have a stop button. One switch that stops the agent taking actions, known to the owner, and tested before launch. Fallback is the manual process, so keep it documented.

Move up the autonomy ladder on evidence. Stay in shadow until accuracy meets the pass criteria on live data. Move from approval to acting within limits only for the case types where reviewers have stopped finding errors over a meaningful volume, and keep approval for everything above the threshold.

An agent that is boring to watch is the goal. If the logs are dull, the overrides are rare for good reasons and the stop button has never been needed, widen the scope one step.

Checklist

0 of 14 done

Ticks are saved in this browser only.

Sources

  1. OWASPTop 10 for Large Language Model Applications, 2025 (LLM01 Prompt Injection, LLM06 Excessive Agency)
  2. NISTAI Risk Management Framework 1.0, 2023
  3. European Commission, AI Act Service DeskArticle 14: Human oversight

Questions

What is the biggest security risk with AI agents?

Prompt injection combined with too much access. OWASP ranks prompt injection first in its 2025 Top 10 for LLM applications, and excessive agency, meaning more functionality, permissions or autonomy than the task needs, sixth. An agent that reads untrusted content and can act broadly is the combination to avoid.

Can prompt injection be fully prevented?

Not reliably with prompts alone. Design so a successful injection does little harm: least-privilege tools, validation of every action outside the model, approvals for consequential actions, and no path from untrusted content to sensitive tools without a check.

When does an AI agent need human approval?

When a mistake costs money, breaks a rule, reaches a customer or cannot be undone, and whenever the agent is making a judgement rather than following a rule. Frameworks such as NIST’s AI RMF tie oversight to impact, and the EU AI Act requires effective human oversight for high-risk systems.

How many test cases does an evaluation set need?

Enough to cover the real variety of the work. For a focused business task, start with 50 to 200 real cases, labelled with the right answer, and include the hard and unusual ones. Add every production failure to the set so it cannot happen twice.

Next

Put it to work.

Cookie preferences

Choose what this site may use on your device. You can change this at any time from “Cookie settings” in the footer.

Strictly necessary

Keep the site working and remember the choices you make here. These cannot be switched off, and none of them track you.

Always on
What this includes (4)
NameProvider PurposeDuration
sbd-consentThis site Remembers your cookie choices12 months
Vercel Web AnalyticsVercel Inc. Counts page views in aggregate. Sets no cookie and stores nothing on your deviceNone
ticker-dismissed, sbd-note-offThis site Remembers that you closed a notice or language tipUntil the tab closes
sbd-voice-resume, sbd-voice-prefillThis site Carries a voice conversation across pages, only if you start oneUntil the tab closes

Analytics

Tell us which pages are read and where visitors leave, so we can improve them. IP addresses are anonymised and nothing is used for advertising.

What this includes (2)
NameProvider PurposeDuration
_gaGoogle Analytics (Google LLC) Distinguishes visitors with a random ID13 months
_ga_FPXDMQPRV1Google Analytics (Google LLC) Keeps the session state for this site13 months

Functional

Embedded services that set their own cookies. Without them the site still works; you get a link to open the service instead.

What this includes (1)
NameProvider PurposeDuration
Booking calendarCal.com Inc. Shows live availability and books the call on the booking pageSet by Cal.com

Advertising

Not used. This site has no advertising, retargeting or social media tracking, and we never sell data.

Not used

Questions about your data: hello@smallbaydigital.com