The Dual LLM pattern is an architectural defense against prompt injection in which an application uses two separate language model roles: a privileged LLM that plans actions and may call tools but never reads untrusted content, and a quarantined LLM that processes untrusted content but has no tool access. Ordinary, non-LLM controller code sits between them and passes untrusted results only as symbolic references, never as raw text.
In AI security, the pattern is significant because it does not try to make a model resistant to malicious instructions. Instead, it constrains what a compromised model can do, treating prompt injection as an unsolved problem that must be contained by system design, much as classic security isolates untrusted input from privileged code.
How the Dual LLM pattern isolates untrusted content
The pattern works by separating control from data. The user’s request goes to the privileged LLM, which decides what to do. Whenever the task needs untrusted content, such as an email, a web page or a retrieved document, the controller sends that content to the quarantined LLM and stores the result in a named variable such as $VAR1. The privileged LLM only ever sees the variable name.
Because the privileged model never reads the injected text, malicious instructions cannot steer tool calls. The quarantined model may be fully manipulated, but it has no ability to act: it can only return text that the controller treats as opaque data. The controller finally substitutes variable contents when displaying results to the user or passing them to a tool argument.
| Component | Sees untrusted data | Can call tools | Responsibility |
|---|---|---|---|
| Privileged LLM | No | Yes | Plans steps and chooses actions |
| Quarantined LLM | Yes | No | Summarizes, extracts or transforms content |
| Controller | Handles it as opaque data | Executes approved calls | Routes data and enforces isolation |
| User | Yes, at display time | Approves sensitive actions | Final judgment on outputs |
Origin and design principles
The Dual LLM pattern was proposed by Simon Willison in 2023 as a response to the observation that detection-based defenses against prompt injection, such as classifiers or prompt hardening, reach high but never complete reliability. In security, a defense that fails one time in a hundred is an open door for a determined attacker, so the pattern relies on architectural guarantees instead of probabilistic filtering.
- Least privilege: the model exposed to attacker text holds no capabilities.
- Taint isolation: untrusted outputs stay tainted and are referenced, not interpreted.
- Deterministic mediation: plain code, not a model, decides what crosses the boundary.
- Human checkpoints: consequential actions remain subject to user confirmation.
The two roles do not require two different models. The same base model can serve both, because the protection comes from separate contexts and separate permissions, not from model choice. Many implementations use a smaller, cheaper model for the quarantined role, since summarization and extraction rarely need the strongest reasoning, which also lowers the per-request cost of the extra calls.
The pattern also appears in later research catalogs of agent security design patterns, alongside action-selector, plan-then-execute and context-minimization designs. These catalogs share one principle: once an agent has read untrusted input, its ability to take consequential actions must be restricted.
Comparison with related prompt injection defenses
The Dual LLM pattern is one of several design-level defenses for agents, and it is often combined with detection-level controls. The table compares it with neighboring approaches in the same threat model.
| Defense | Mechanism | Guarantee strength | Main cost |
|---|---|---|---|
| Dual LLM pattern | Privilege separation between two model roles | Strong for control flow | Complex orchestration |
| CaMeL | Planner code plus capability tracking on data | Strong for control and data flow | Engineering effort, reduced flexibility |
| Spotlighting | Marks or encodes untrusted text in the prompt | Probabilistic | Little; easy to adopt |
| Instruction hierarchy | Trains model to prefer system instructions | Probabilistic | Requires model training |
| LLM firewall | Classifies inputs and outputs for attacks | Probabilistic | False positives, bypasses |
CaMeL, introduced by Google DeepMind researchers in 2025, extends the idea: the privileged model writes a program, a custom interpreter executes it, and capability labels on every value enforce policies on where tainted data may flow. It addresses a gap in the original pattern, which protects which actions run but not always which data reaches them.
Residual risks and failure modes
The pattern blocks the most dangerous class of attack, an injected instruction that triggers a tool call, but it leaves several residual risks that designers must handle explicitly.
| Risk | How it arises | Mitigation |
|---|---|---|
| Manipulated output to user | Quarantined LLM returns a deceptive summary | Show provenance and keep users aware |
| Data flow abuse | Tainted variable used as a tool argument, such as a recipient | Policies on tainted arguments, confirmation |
| Leaky orchestration | Developer passes raw content to privileged LLM | Code review and type-level taint markers |
| Exfiltration through rendering | Output contains links or images that leak data | Strip or sanitize markup before display |
| Reduced capability | Privileged LLM cannot reason over content it never sees | Narrow tasks or accept the trade-off |
The last risk is the central trade-off: an agent that cannot read a document cannot decide based on its content. Tasks such as “reply to whatever this email asks” fall outside what the pattern can secure, because the untrusted text is the instruction.
When to apply the pattern
The Dual LLM pattern is most valuable when an agent combines the three elements of the lethal trifecta: access to private data, exposure to untrusted content and a channel to communicate externally. Removing the overlap of these elements in a single model context is exactly what the pattern achieves.
- Email and calendar assistants that read external messages and can send mail.
- Browsing agents that read web pages and hold credentials or session tokens.
- RAG systems whose retrieved documents may contain planted instructions.
- Support bots that process customer text and can modify accounts.
For low-risk, read-only assistants, the orchestration overhead may outweigh the benefit, and spotlighting plus output filtering may suffice.
A plain-language summary
The Dual LLM pattern works like an office with two assistants who never swap roles. One assistant holds the keys and can act. The other reads incoming mail from strangers but holds no keys.
If a letter contains a trick, such as an order to send money, only the reader sees it. The reader cannot act on it. The key holder only hears that letter number one arrived. Tricks in outside text cannot reach the one who acts. The cost is that the key holder knows less about what the letters say.
An example from practice
A software company builds an internal assistant that summarizes inbound vendor emails and drafts calendar invitations. Security testing shows that an email containing hidden text, telling the assistant to forward the inbox to an external address, succeeds against a single-model design in some trials.
The team rebuilds the assistant with the Dual LLM pattern. The privileged model receives requests such as summarizing new vendor mail and scheduling follow-ups; the quarantined model writes each summary into a variable, and the controller shows summaries directly to the employee. Meeting invitations use only attendees selected from the internal directory, never addresses extracted from email text. In a repeat test of the same injection attempts, no unauthorized tool call occurs, while summary quality remains comparable.