To add an LLM to a legacy application, put the model behind a separate adapter service and leave the legacy core in charge. The adapter acts with the signed-in user's identity, offers the model a few typed tools, reads only what that user may see, and proposes changes that your existing business rules validate before anything is saved.
Below you will find what to build and where each boundary sits. The order of work, from the first pilot to a full release, belongs in a staged LLM rollout plan for legacy software.
The reference architecture has five parts, and only one of them is new code that talks to the model. The legacy core keeps its database, rules and release process, while the adapter service owns everything that changes when prompts or models change.
| Part | What it owns | What it never does |
|---|---|---|
| Legacy core | Records, business rules, its release process | Call the model directly |
| Adapter service | Prompts, model calls, tool definitions, output checks, AI logs | Hold an administrator account or write to the database |
| Model endpoint | Text generation, hosted or self-hosted | Receive requests from anything except the adapter |
| Read side | Permission-filtered APIs, a constrained read replica or a retrieval index | Change a record |
| Write side | The application's existing business APIs | Accept a change that skipped validation or confirmation |
The split follows from one fact: prompts, model versions and output checks change on a different schedule from legacy code. When they all live in the adapter, the legacy release train carries no AI changes, and switching a feature off is a configuration change.
Putting the LLM beside the core keeps every AI change out of code your team is afraid to touch. A wrong prompt or a slow model then breaks one feature, and the screens, transactions and reports that already work stay as they are.
The seam borrows from the strangler fig pattern. AWS Prescriptive Guidance describes it as replacing a monolith one component at a time, with a proxy layer routing each request to the old or the new system, and an anti-corruption layer that "works as an adapter or a facade" between them. Our goal is narrower: we add a capability and leave the system in place. The adapter does the same job as that facade, and if you later replace parts of the core, the seam is already there.
The AI adapter service turns one business task into one model call with checked output. The legacy application calls task-shaped endpoints, never a generic "send this prompt" endpoint.
A support screen, for example, calls a summarise-ticket endpoint with only a ticket ID. The adapter then:
- Fetches the ticket through the read side, as the signed-in user.
- Builds the prompt from a versioned template.
- Calls the model with a timeout.
- Checks the output against a schema.
- Returns a typed result: a summary that references the messages it used, or a typed failure.
Plan for failure from the first call. When the adapter is slow, down or returns output that fails validation, the legacy screen behaves as it did before the feature existed. Keep model calls out of transactions that must not fail, such as checkout or payment posting, and put long jobs, such as summarising large documents, on a queue whose results appear when ready.
Prompt templates, model versions, tool lists, limits and feature flags live in the adapter under version control and review, so nobody hunts for them in legacy code.
Illustrative support example: the legacy screen sends only a ticket ID. The adapter fetches the ticket as the signed-in user, calls the model and checks the output, then returns either a checked summary or a typed failure. On failure the screen works as it did before.
The model acts as the signed-in user, and the adapter learns who that is from your server, never from the prompt. The legacy application passes the authenticated user as a short-lived signed token, or a gateway attaches it, and the adapter forwards that identity on every data call.
The same rules that govern the legacy screen then check every read. Do not give the assistant one powerful service account: with a shared administrator account, someone can talk the model into requesting records the user could never open. Nothing in a question, a retrieved document or a tool result may change identity, so a message claiming to come from an administrator changes nothing.
Background jobs without a user, such as overnight summaries, get their own service identity, limited to that job's data and logged separately. Document search follows the same rule at the index, which is how permission-aware retrieval for company documents works: filter by permission before any passage reaches the model.
Give the LLM only small, typed tools that map to business APIs you already trust. Most legacy features need no tools at all: the code fetches the record, and the model summarises, classifies or drafts.
Anthropic's engineering guide to building effective agents separates workflows, where code runs "predefined code paths", from agents, where the model directs its own tool use, and recommends "finding the simplest solution possible". Whether a feature needs more autonomy is a business decision first; our CTO guide to when an agent is worth it helps you make it.
OWASP's Top 10 for LLM Applications (2025 edition) lists excessive agency as a risk, caused by excessive functionality, permissions or autonomy. Its mitigations match this design: minimise tools, minimise their permissions, run them in the user's context and require user approval. In practice, each tool is:
- Narrow and typed.
get_order_status(order_id), never "run SQL" or "fetch any URL". - Mapped to an existing business API, reusing its validation and permission checks.
- Read-only by default. A tool that would change data returns a proposal for a person to confirm.
- Bounded by allowlists, rate limits and input validation, as any untrusted request would be.
The same OWASP list puts prompt injection first. Treat tool results and retrieved text as data, never as instructions: a record containing "ignore previous instructions" must not trigger another tool or widen access.
Reads and writes take different paths, and the model never commits a change itself. The read path answers questions within the user's permissions; the write path turns a model's draft into a change only after validation and confirmation.
Read-only access still needs care. It can expose sensitive information, and a wrong answer can lead someone to a bad decision, so permission checks, testing and source references stay on the read path too. For reporting questions, expose a fixed set of views on a read replica, never free-form SQL on production.
On the write path:
- The model produces a structured proposal.
- The legacy application validates it with the same rules as a manual entry.
- The user sees what will change, line by line, and confirms.
- The existing API commits it under the user's identity, with an idempotency key so a retry cannot apply it twice.
- The audit record notes that the assistant drafted the change and who approved it.
An illustrative example: a support agent asks the assistant to refund a damaged item. The assistant reads the order and the refund policy through read-only tools, then drafts a refund request with the amount, reason and policy reference. The legacy refund service validates it as it would a manual request, the agent confirms, and the refund posts under the agent's account. If validation fails, the draft comes back with the reason and nothing has changed.
Illustrative refund example from the article: the model drafts a refund request, the legacy refund rules validate it as they would a manual entry, the support agent confirms the change, and only then does the existing API commit it under the agent’s identity. Here the draft has not been saved.
Every LLM feature needs a trace, a test set, a spending limit and its own off switch before real users see it. These controls sit in the adapter, so none of them waits for a legacy release.
- Trace every request with one correlation ID across the legacy screen, adapter, model and tool calls.
- Log what a review needs: the user, prompt and model versions, tool calls, record IDs, output and validation result. Restrict access to these logs, set retention limits and redact sensitive fields.
- Set limits on requests and spend per user and per feature, so a runaway loop stops at the limit.
- Keep a kill switch per feature, independent of legacy releases.
- Test before every change to prompts, models or tools, with cases for correct answers, refusals, permission boundaries and injection attempts. Start by measuring groundedness with labelled examples, then decide what must pass with release gates for LLM features.
Each of these shortcuts lets the model into your core, and each has a direct replacement.
| Shortcut | What goes wrong | Do this instead |
|---|---|---|
| Calling the model from the browser or mobile app client | The API key ships to every user | Call the adapter from your server |
| A generic SQL or HTTP tool "for flexibility" | One injected instruction can read or change anything | Narrow, typed tools on business APIs |
| One shared administrator account | Any prompt can escalate privileges | The signed-in user's identity on every call |
| A synchronous model call inside a critical transaction | A slow model blocks checkout or payments | A queue, or a call outside the transaction |
| Model output written straight to records | Unvalidated changes reach your system of record | A proposal, validation and user confirmation |
Start with one task-shaped feature on the read path, add typed tools and the write path only when a feature needs them, and keep the identity rule fixed throughout. Before you write code, check five things: the adapter is the only caller of the model, every data call carries the user's identity, every tool maps to an existing business API, every write waits for confirmation, and each feature has its own off switch.
If you want a second pair of eyes on these boundaries in your own system, our team offers custom AI development that starts with an architecture review of your application.
- Amazon Web Services. Strangler fig pattern. AWS Prescriptive Guidance, cloud design patterns.
- Anthropic. Building effective agents. Published December 2024; the page notes that much of the tooling it describes has changed since then.
- OWASP GenAI Security Project. LLM06:2025 Excessive Agency, part of the OWASP Top 10 for LLM Applications (2025 edition).
The architecture and recommendations in this article are TecnoStack's engineering guidance, not requirements set by AWS, Anthropic or OWASP. Sources checked in October 2026.






