AI agents
Agent harness: run AI agents reliably in a SaaS app
The model is not the bottleneck. The harness around it decides whether an agent survives production.
In brief
A production agent harness is the software around the model that makes it safe to run inside a real SaaS product. It has a tool registry mapped to your existing API endpoints, a permission check on every tool call, a workflow engine that splits work into small steps with retries and timeouts, saved state so a run can resume, human approval points for risky actions, and tracing and evaluation on every step.
On this page
01What components make up an agent harness?
Vendor docs each cover one piece: tools, durable execution or tool approval. A staff engineer has to assemble them inside a product that already has tenants, roles and business rules. We call that assembly the agent harness, and we treat it as part of the product, not a side service.

Here is the reference architecture we use when we add agents to an existing SaaS application. The product stays the system of record; the harness sits between the user surface and the backend you already run.
Use this table as a component checklist when you review a design.
- 01
Capture the user intent with the session identity and tenant.
- 02
Build product context from data that user can already access.
- 03
Offer the model only the tools allowed for that agent and that user.
- 04
Run a permission check on every proposed tool call, in code, not in the prompt.
- 05
Route risky actions to a human approval step.
- 06
Execute the action through the existing API.
- 07
Evaluate the result against the expected outcome for that step.
- 08
Write the audit record, including any approval.
| Component | What it does | Failure it prevents |
|---|---|---|
| Context builder | Pulls only the records the current user is allowed to see | Answers built on data from the wrong tenant or role |
| Router | Sends each request to one narrow agent or a fixed workflow | One general agent picking the wrong tool among dozens |
| Workflow engine | Runs work as small steps with retries, timeouts and saved state | Half finished runs that nobody can resume or explain |
| Model gateway | Central place for model choice, rate limits and token cost | Surprise bills and outages when one provider slows down |
| Tool registry | Typed, versioned tools that wrap real backend endpoints | The model inventing actions or calling internal functions directly |
| Policy check | Checks identity, role, tenant and business rules on every call | An agent doing something the user could not do themselves |
| Approval gate | Pauses risky actions until a person approves | Irreversible writes made on a model guess |
| State store | Keeps checkpoints, idempotency keys and short term memory | Duplicate writes after a retry, lost progress after a crash |
| Tracing and evals | Records inputs, outputs, latency and cost for each step and scores quality | Silent quality drift after a prompt or model change |
| Audit log | Keeps a readable record of request, action and approver | Failed customer security reviews and unanswerable incident questions |
The flow for a single request follows the order we use in our own harness design:
02How should tools and permissions be defined?
A tool is a contract, not a suggestion. Each tool should map to one real endpoint, with a typed input schema, a description written for the model, a declared side effect level and an owner. Anthropic's guidance on building agents makes the same point: toolsets and their documentation deserve clear, careful design, in the same way prompts do.

We define tools with these rules:
- One tool, one job. "update_booking_time" beats "manage_booking"; narrow tools are easier to test and permission.
- Wrap existing endpoints. Tools call the same API your web app calls, never the database directly.
- Label the side effect. Read, draft, write or irreversible. The label drives approval rules.
- Pass the user's identity, not a service account. The tool call carries the session token of the person who asked, so the backend applies the permissions it already enforces.
- Validate before and after. Reject malformed calls instead of repairing them.
Permissions belong in code that runs on every call. A prompt saying "only act on this customer's records" is an instruction the model may follow. A policy check comparing the tenant id in the arguments with the session is a control it cannot talk its way around. The rule we apply is simple: an agent should never be able to do anything the user could not do in the product by hand. A mature product already enforces tenant boundaries, roles and business rules; the harness reuses them.
The OWASP Top 10 for LLM Applications calls this risk excessive agency. Its mitigations match this design: minimal tools, tool calls run in the user's context with minimum privileges, human approval for high impact actions, and authorization enforced in downstream systems, not by the model.
03Why break agents into small, narrow steps?
Reliability falls as the decisions in one model call rise. A general agent with forty tools must choose correctly at every turn. A small step has one goal, a short tool list and known inputs and outputs, so it can be tested, retried and moved to a cheaper model on its own.
Anthropic distinguishes workflows, where code defines the path and the model fills in steps, from agents, where the model decides its own path. Its advice is to find the simplest solution that works and add complexity only when needed. In established SaaS we split work into narrow steps early, because the product already has many workflows with different permission rules.
Narrow steps also make evaluation practical: one test set per step, run on every release. We describe the underlying idea in why AI agents fail in production: probabilistic reasoning needs deterministic control around it. His CARE lens (consistency, autonomy, reliability, explainability) is easier to satisfy one small step at a time than across one long, open ended run.
04How do we handle retries, timeouts and partial failures?
Agent runs fail in ordinary ways: model timeouts, rate limits, slow APIs, workers restarting mid run. The harness treats these as normal events.

Durable workflow engines such as Temporal are built for this. Temporal's documentation on AI covers durable agents, with each step running as an activity that has its own retry policy and timeout, and with workflow state saved so a run continues after a crash instead of starting over. A queue and a state table can do a lighter version with the same rules:
- Timeout every step. Model calls, tool calls and human waits each get their own limit.
- Retry only what is safe to retry. Transient errors such as timeouts and rate limits get retries with backoff. Validation errors and permission denials do not.
- Make writes idempotent. Every write tool takes an idempotency key stored in the state store, so a retry after a network failure does not create a second booking, invoice or message.
- Checkpoint after each step. Resume from the last completed step and reuse earlier model outputs, which keeps cost and behavior stable.
- Plan compensation for multi step writes. If step four fails after steps one to three wrote data, the workflow either runs a defined undo or parks the run for a person with full context.
- Send exhausted runs to a human queue, with the trace attached.
We measure the result as cost per successful task, not cost per call. A cheap step that fails often and retries three times is not cheap.
05Where do humans approve or intervene?
Place human approval by risk, not everywhere. Too many prompts and people click through them; too few and an agent acts on a guess. The capability ladder from the same article gives a clear way to place them: read, recommend, prepare, modify, execute. Each step up needs more policy, more approval, stronger idempotency and a fuller audit trail.
In practice we apply three patterns:
- Draft and approve. The agent prepares a message or record; a person approves it before anything is sent or saved.
- Approve the action, not the reasoning. The approval screen shows exactly what will change, with the source data linked.
- Escalate with context. When the agent is unsure, hits a policy limit or exhausts retries, a person gets the case with the steps taken and the trace.
Microsoft's Agent Framework documentation shows function tools that can be marked as requiring human approval, so the run pauses and returns an approval request instead of executing. OWASP also recommends human approval for high impact actions. Keep the request, the decision and the approver in the audit log; customer security reviews ask for that record.
This is the layer most teams skip when they add AI agents to an existing SaaS product.
06What we see in production
Three examples from our work show the pattern.
An industrial contractor's reporting database. Leaders wanted plain language answers on live job cost data from the Copilot agent the company had already built, and every figure had to match the existing reports exactly. No data could leave the company's network, and access had to stay read only and least privilege.
We kept the agent the client had already secured and gave it one narrow way to the data: a small deterministic tool that validates and runs approved read only queries against an agreed set of views. We ruled out letting the model write and run free form SQL against the database. The lesson: if a query is not on the approved list, the agent cannot run it.
A hardware design engine. Inventors who are not electrical engineers wanted to describe a device in plain words and get a design a real manufacturer accepts. We split one request into separate modules, each with the technique that fits it: language AI only reads the request, while rules and search choose the parts, place them and route the board, with checks between steps. The lesson: narrow modules make each output something a reviewer can check, and every design is checked before any file exists.
A sales training platform. Sales teams learned a structured script through roleplay with coaches, which did not scale and gave uneven feedback. The goal was voice practice calls with an AI prospect at any time, scored consistently against the client's own checklist. We started with a short proof of concept with hard coded scenarios, then moved scripts, scenarios, checklists and global AI instructions into the database so admins control the AI. Feedback runs as an orchestrated workflow of small steps. The lesson: prompts and rubrics are product configuration, and the people who own the content should control them.
On a team AI chat product built on an old open source fork, we took model routing out into its own service in front of the original provider and others, so adding a model no longer means changing the app, and every custom feature moved onto a current upstream release.
What these products share is what we left alone: the core product, its data model and its permission logic. The harness changed only what the AI capability required.
Frequently asked questions
Do we need a durable workflow engine like Temporal?
Not always on day one, but you need its guarantees. Any agent that writes data, waits for a human or runs longer than one request needs saved state, per step timeouts, retries and resume after a crash. A durable engine such as Temporal provides those. A queue plus a state table can work for simple flows, but you then own the retry, timer and resume logic yourself.
One general agent or many narrow agents?
For established SaaS products we favor many narrow agents behind a router. Each agent has one goal, a short tool list and its own permissions, so it is easier to test, evaluate and debug. Once agents write data across workflows with different permission rules, narrow agents are more predictable and easier to audit.
How do we version prompts and tools?
Treat prompts, rubrics and tool schemas as versioned configuration. Store each version with an id, record that id in every trace and audit entry, and run your evaluation set before promoting a change. Tool schemas follow API versioning rules: add fields freely, and publish a new version for breaking changes.
How does the harness connect to our existing backend?
Through the APIs your product already exposes, called with the requesting user's identity. Each tool wraps one endpoint, so your existing permission checks, tenant boundaries and business rules still apply. The agent never connects to the database directly. Where an endpoint is missing, add a small, targeted API rather than giving the agent internal access. The harness runs in your cloud next to the product.
How Datics helps
Datics specializes in Brownfield AI: production AI inside software people already rely on. A Build Sprint puts one outcome working in your product's staging in three weeks, for $10,000, and the fee counts toward production. Not sure what to build first? The Planning Sprint ranks it in two weeks, for $5,000.
Related work
Case studies from our projects on the same subject.
A European team AI chat provider
Other software · Multi-model team AI chat
Team AI chat moved onto current open source, every custom feature kept
A team AI chat product had its own features stuck on an outdated open source fork. We carried them onto a current base, open to more AI models.
SovrenAI
Other software · Enterprise Builder, an AI internal app builder
Teams build internal apps on company data, a person confirming each guessed join
An agent writing queries over unknown schemas can join the wrong tables; here every guessed join waits for a person to approve it.
CleanHaus
Property Management · Turnover operations SaaS
Hosts and cleaners manage rental turnovers in chat, within each person's permissions
Owners, managers and cleaners all talk in one property chat. Now an AI there acts for each of them, only within that person's role.
More on AI agents
AI agents
AI agents for business: put them to work inside your SaaS
AI agents for business work best inside the SaaS product you already run: your APIs as tools, your permissions as the boundary, human approval on writes.
AI agents
How do you design tools for LLM tool calling?
LLM tool calling works in an existing product when each tool maps to a real, approved endpoint with a clear name, description and schema. Here is how.
AI agents
Enterprise AI agents: what separates them from demo agents
Enterprise AI agents act as the signed-in user, use a fixed set of tools, wait for approval on risky steps, log every call and are tested on real cases first.
AI agents
Which AI agent architecture fits a high-stakes workflow?
For a high-stakes workflow, the stronger AI agent architecture is a supervisor routing to narrow sub-agents, each with a contract and a human decision point.
AI agents
How much autonomy should AI agent guardrails allow?
AI agent guardrails that work: agents read and draft freely, but need consent and an editable confirmation before moving money, changing records or messaging.
AI agents
Where should AI agent security enforce permissions?
AI agent security in a multi-role SaaS product rests on one rule: the agent gets the user's permissions and nothing more, enforced in code, never in the prompt.
Your customers already expect AI from your product.
Let us make it real inside the product you run today.
