Skip to content

Integrating AI agents with legacy systems

Alex Vakhitov, founder of Comonad Limited

Written by Alex Vakhitov, founder of Comonad Limited. Published

On this page

Operating agents against legacy systems is not the same as modernising them

Two different jobs get called legacy work. One is rewriting or migrating old code, which coding agents can help with behind tests. How those tests stay independent of the agent is in Verifying AI-written code. We cover the rewrite itself under legacy modernisation with AI agents. The other is an agent doing work in a system that stays where it is: reading its records, raising requests in it, changing what it holds. This guide is about the second job.

That matters because you do not have to replace a system of record before an agent can be useful against it. The Australian Signals Directorate's guidance on agentic AI harnesses (opens in new tab) notes that many of the highest-impact organisational risks emerge when the model is connected to enterprise data, systems and tools. That is why the connection is where the engineering goes.

The integration layer: typed business operations

Put a small layer between the agent and the system, and give the agent a short list of named business operations: find the invoice exceptions for this supplier, propose a hold on this payment, add a note to this case. Each operation has typed inputs and a defined result. The agent never gets tables, a generic query endpoint or a login to the screens.

There are four reasons. A narrow surface is a narrow authority; OWASP's entry on excessive agency (opens in new tab) names excessive functionality and permissions as the usual causes of harm. Every call can be validated, because the layer knows what a good call looks like. The layer is the single place where checks, limits and records are enforced, which is the role we describe as an action gateway. And it keeps the legacy system's oddities out of the agent's reach, so a change inside the system touches one adapter and not every prompt. The layer is a seam and not a permanent home for the old system. When the system is replaced, the operations the agent uses stay the same and the adapter underneath changes.

When there is no API

Many old systems have no usable API. There are still ways in, and some are better than others. Prefer the lowest-risk route that gives the agent what its task needs.

Ways to reach a system with no API

Route
A supported export or report
Suits
Reading, reconciliation, triage
Extra controls
Treat the file as untrusted input; record which export the agent used
Route
A read-only database view or replica
Suits
Reading at scale
Extra controls
Expose views, not tables; restrict columns; no write path
Route
A message queue or batch file exchange
Suits
Proposing changes the system already accepts this way
Extra controls
Validate before sending; idempotency keys; reconcile on the next cycle
Route
Vendor-supported or in-house adapter
Suits
Reads and writes that the system owner will stand behind
Extra controls
Version the adapter; test it against the system's own rules
Route
Screen automation
Suits
Last resort, when no other route exists
Extra controls
A dedicated seat for the agent; read-only first; capture what was on screen; expect it to break when the screen changes

Whichever route you pick, the agent talks to your integration layer, not to the route. That lets you change the route later without changing the agent.

Identity and access: the agent's own, with nothing standing

The agent gets its own identity. NIST's design tenets for agent identity (opens in new tab) say agents should be distinguishable from human users and service accounts, and describe agents impersonating a person or a service account as a dangerous practice. An agent that logs in as the person who asked for the work does everything that person can, and its actions look like theirs in the logs.

Some old systems only know named users and shared accounts. Create a dedicated account for the agent, mark it as non-human, give it the narrowest role the system allows and keep its credential only in the integration layer, never in the model's context. Where the system cannot issue short-lived access, rotate the credential and hold it so that it is used for one operation at a time. NIST's tenets describe zero standing privilege and access that is time-bounded and revocable, and that is the target even if you reach it in stages.

Read-only first

An agent can do useful work before it changes anything. It can triage a queue, group items by cause, summarise a case history, draft a reply, compare two systems and find records that do not reconcile. The ASD's advice is to start with low-risk use cases, implement appropriate controls, maintain human oversight and expand only as controls mature.

Read-only is not harmless. The agent can expose data it should not and can be steered by what it reads. The UK National Cyber Security Centre's blog on prompt injection (opens in new tab) says that where a system calls tools based on a model's output, the impact of an attack becomes whatever direct access to those tools would give an attacker. Free-text notes, attachments and emails inside a legacy system can carry instructions. Treat everything the agent reads as untrusted, and keep its read access to what the task needs.

Shadow running: the agent proposes, people act

In shadow mode the agent works on real cases and writes down what it would do, but a person does the work as before. Afterwards you compare the two, with a script you can rerun and not by eye. Sort each difference into three kinds: the agent was wrong, the person was wrong, or both were defensible. The first kind tells you what to fix. The second shows up inconsistency that was already there, which is often useful to the owner.

Write the exit criteria before you start, as a comparison that can be rerun, and let the owner of the process decide whether they are met. We do not set a calendar for it. Shadow running lasts until the evidence supports moving on, and the person accountable for the outcome makes that call.

Re-using the approval workflow you already have

Most organisations already have a way to approve a payment, a change or an exception. Use it. The agent raises the request in that workflow under its own identity, with the evidence attached, and the same approver decides as would for a person's request. The agent never approves its own request. People who already know that workflow need no new tool, and the record sits in the place auditors already look.

Keep the volume sensible. NIST's fifth tenet warns of consent fatigue, where escalation is so frequent that approvals become habit. Let routine, reversible actions within written limits run without a person once the evidence supports it, and reserve approval for the rest. If the output feeds a significant decision about a person, UK GDPR applies: Article 22A (opens in new tab) treats a decision as solely automated where there is no meaningful human involvement. Our guide to AI agents and UK GDPR explains what that requires.

Writes that are safe to retry

Old systems were rarely built for a caller that retries. Put these protections in the integration layer, so the agent does not have to be trusted with them.

  • Idempotency. Give each write a key, remember it, and make a repeat harmless.
  • Check, then act. Read the current state just before the write and refuse if it has changed since the agent looked.
  • Read back. After the write, read the record itself, not the agent's report of what it did, and compare it with what was meant. Report any mismatch.
  • Reconcile. Compare the agent's record of what it did with the system's record on a schedule, and flag differences.
  • A way back. Decide before the first write how it will be undone: a compensating entry, a hold that can be released, or a person's manual correction. If nothing can undo an action, it should wait for a person.
  • One write at a time. Keep the first write operations few, narrow and bounded by limits.

A worked example

This example is synthetic. It does not describe a client. A finance team has an exceptions queue: invoices that fail automatic matching against orders and receipts. The ledger is old, has no API and sends nightly exports.

At first, the agent is read-only. From the nightly export, it groups exceptions by cause, such as quantity mismatch, price outside tolerance and missing receipt, and writes a short note on each. The team sees the groups and notes, and works the queue as before.

Then the agent runs in shadow. For each exception it proposes a resolution, and the accountant makes the real decision. Differences are sorted and the owner reads them. Where the agent is consistently right on one cause and not on another, the owner narrows its scope to the first.

Finally, one write is allowed: releasing a payment hold on an invoice when the price difference is within the tolerance in the written policy. The agent raises that as a request in the existing approval workflow, under its own identity, with the matched documents attached. The finance controller role approves, as it would for an accountant's request. The integration layer posts the change with an idempotency key, reads the record back, and reconciles it in the next cycle. Anything outside the tolerance goes to a person as before.

What to record for audit and incident review

The record needs to answer "who, for whom, what, under which rule and what happened" for every action, including refusals and the ones that waited for approval.

  • The agent's identity and the person or function it acted for.
  • The operation requested, its inputs, and what the agent was reading or told when it proposed it.
  • The decision made by the integration layer and the rule version behind it.
  • The approval request and the approver, where one was needed.
  • The result the system returned, the read-back and any reconciliation difference.
  • The shadow-running comparisons that supported letting an action through.

NIST's tenet 10 asks for evidence that is tamper-evident, append-only and independent of the agent, so that it cannot rewrite its own history.

How Comonad helps

If you have a workflow that touches a system of record and want an agent working in it under controls your risk and security teams accept, that is what our enterprise AI agents service does. We design the integration layer, the identity and the approval route in your environment.

Discuss an enterprise AI agent

Sources

Frequently asked questions

Can an agent use a legacy system with no API?

Yes, through a route that fits the task: a supported export, a read-only view, a queue or file exchange, an adapter, or as a last resort screen automation. In every case the agent should talk to a narrow integration layer that you control, not to the route directly.

Should the agent use a person's account?

No. It would inherit everything that person can do, and its actions would look like theirs in the logs. Give the agent its own identity, and where the system cannot, a dedicated non-human account with the narrowest role available.

What is shadow mode?

The agent works on real cases and records what it would do, but people do the work. You then compare the two and sort each difference, so you learn where the agent can be trusted before it changes anything.

When can an agent write to the system of record without approval?

When the action is reversible, sits within written limits set by its owner, is validated by the integration layer, and shadow running has shown it is reliable, as judged by the owner. Actions you cannot undo, or that sit in the never-without-approval group, keep a person in the loop. See delegated authority for AI agents for how to draw that line.

Do we need to replace the legacy system first?

No. An agent can be useful against a system that stays in place, provided the integration layer, identity and approval route are sound. Replacing the system is a separate decision, and the typed operations and acceptance checks you build now describe what a replacement has to do, so the work is not thrown away.

Discuss an enterprise AI agent

Tell us about the workflow, the system of record it touches and who would own the agent.

Discuss an enterprise AI agent