Skip to content
EqualStack
AI & ML

AI agents in production: when to use them and how to keep them safe

What AI agents are good at, when a simpler workflow beats them, and the guardrails that let an agent act in real systems without surprises.

EqualStack engineering teamSenior engineers3 min read

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

  1. Shadow mode: the agent proposes actions, people do the work, and you compare.
  2. Assisted mode: the agent prepares actions, people approve each one.
  3. 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.

Enjoyed this? Get a practical note twice a month.

Engineering lessons, case studies and guides like this one, from the senior team that wrote it.

No spam. Unsubscribe anytime.

Written by

EqualStack engineering team

Senior engineers

Written by the senior engineers who design, build and run our clients' products.

About us

Keep reading

Related articles

AI & ML3 min read

RAG in production: 7 lessons from shipping AI assistants

Retrieval-augmented generation is easy to demo and hard to run. Seven practical lessons on chunking, evaluation, access control and cost.

AI & ML4 min read

Adding AI to your product: where it pays off and where it doesn't

A practical guide for product leaders: the AI use cases that reliably deliver value, the ones that disappoint, and how to ship an AI feature without the risk.

AI & ML3 min read

Choosing an LLM for your product: quality, cost, speed and privacy

How to pick the right large language model for each feature in your product, balancing answer quality, cost, response time and data privacy.

Have a project in mind?

Tell us what you're building. A senior engineer will reply within one business day with questions, ideas and next steps.