An AI agent is a language model that can decide which steps to take and call tools to take them: search a knowledge base, query a database, create a ticket, send an email. That flexibility is what makes agents exciting, and also what makes them risky. Here is how we decide when to use one, and how we keep it safe once it can act on real systems.
Agent or workflow?
Many problems described as "we need an agent" are better solved with a fixed workflow that uses a model at specific steps. A rule of thumb:
- Use a workflow when the steps are known in advance: classify the email, extract the fields, look up the customer, draft a reply. Each step is predictable, testable and cheap.
- Use an agent when the steps genuinely depend on what the model finds along the way: investigating an issue across several systems, answering questions that need different tools each time, or handling requests that vary widely.
Workflows are easier to test, cost less and fail in clearer ways. Start there, and reach for an agent only where the flexibility is worth it.
What agents do well
- Research and triage across tools. Pulling information from a CRM, ticketing system and documentation to summarise a customer's situation for a support agent.
- Multi-step internal tasks. Preparing a report that needs data from several sources, then formatting it for a specific audience.
- Guided operations with approval. Proposing a set of changes, such as refunds, account updates or follow-up emails, for a person to approve in one click.
Notice the pattern: the agent does the legwork and a person makes the final call on anything that matters.
The guardrails that matter
1. Give the smallest set of tools
Every tool an agent can call is something it might call at the wrong time. Expose only what the task needs, with narrow, well-named functions such as getOrderStatus rather than a general "run any query" tool.
2. Separate reading from acting
Reading data is low risk. Changing data, sending messages or moving money is not. Let the agent read freely, but route any action with consequences through an approval step, at least until you have evidence it behaves well.
3. Validate every tool call
Treat the model's tool calls like input from an untrusted user. Check types, ranges and permissions before executing anything. If the agent asks to refund an amount larger than the order, the code should refuse, whatever the model says.
4. Set limits on steps, time and cost
Agents can loop. Cap the number of steps, the total time and the token budget per task. When a limit is reached, stop and hand over to a person with a summary of what was tried.
5. Watch for prompt injection
If an agent reads emails, web pages or documents, those can contain instructions written to manipulate it. Keep untrusted content clearly separated from instructions, never let content grant new permissions, and keep humans in the loop for sensitive actions.
6. Log everything
Record each step: what the agent saw, which tool it called, with what arguments, and what came back. When something goes wrong, and it will, this trace is how you understand and fix it.
Test agents like any other system
Build an evaluation set of realistic tasks with known good outcomes, including tricky and adversarial cases. Run it on every change to prompts, tools or models. Track success rate, steps taken and cost per task. Release changes only when these numbers hold or improve.
Roll out gradually
- Shadow mode: the agent proposes actions, people do the work, and you compare.
- Assisted mode: the agent prepares actions, people approve each one.
- Partial automation: low-risk, high-confidence actions run automatically; the rest still need approval.
Move between stages based on measured results, not enthusiasm.
The short version
Use a fixed workflow when the steps are known and an agent when they are not. Give agents few, narrow tools, validate every call, cap their steps and cost, keep people approving consequential actions, and log everything. That is how agents become useful in production rather than a demo that never ships.
For the retrieval side of AI systems, see RAG in production: 7 lessons from shipping AI assistants. To talk through an agent idea, see our AI & ML services or book a free 30-minute call.