Skip to content
Montevive
Blog

News

How to control AI agents in production: the AEPD Rule of Two

·Chema Robles·Artificial Intelligence, Cybersecurity
Diagram of three risk conditions for an AI agent, with only two active

In short. An AI agent in production has to be controlled while it acts, not only before it is deployed. The February 2026 guidance from Spain's data protection authority, the AEPD, includes the Rule of Two. An agent should not combine three capabilities: reading untrusted input, accessing sensitive data and taking automatic actions without supervision. If it has all three, remove one or put a safeguard in its place.

Contents


What the AEPD Rule of Two for AI agents is

The Rule of Two is a minimum security threshold under which an AI agent may meet at most two of three conditions: untrusted input, access to sensitive information and automatic action.

The Spanish Data Protection Agency (AEPD) sets it out in its guidance Inteligencia artificial agéntica desde la perspectiva de protección de datos (agentic AI from a data protection perspective), available in Spanish. The guidance dates from February 2026 (current version: 1.2), and the AEPD announced it on 18 February 2026. The rule appears in the risk management section, on pages 41 and 42.

The AEPD did not invent it. The guidance itself explains that it began in the Chromium project as a security rule for the browser. Several authors later adapted it to AI agents, among them Meta. The AEPD presents it as a "minimum threshold of safeguards that must never be crossed" (quotes from the guidance are our translation).

ConditionWhat it means in a real agent
1 · Untrusted inputThe agent reads external emails, web pages, attachments or customer messages that may carry hidden instructions.
2 · Access to sensitive informationThe agent can query personal data, credentials, the ERP, the CRM or internal repositories.
3 · Automatic actionThe agent sends, writes, deletes, pays or changes something without a person approving it first.

The guidance's example is an agent that replies to emails automatically. That agent receives messages with no safeguards against technical or social engineering attacks, has unrestricted access to sensitive information and replies, writes to its memory or changes other repositories on its own. For the AEPD, that is "an agent configuration that should not be allowed".

Why an AI agent has to be controlled while it works, not only before

An AI agent has to be controlled during execution because its behaviour does not repeat reliably. The same request can produce different sequences of actions in two runs. So a test carried out before deployment does not guarantee what the agent will do afterwards.

The AEPD guidance says so in its section on non-repeatable behaviour (pages 30 and 31). A small change in the environment, such as "a different token or a delay in an API call", can throw the whole plan off course. The AEPD's conclusion is blunt: prior verification, "including audits, regression tests and regulatory validation processes, becomes fragile".

That does not make the prior audit pointless. It means you need both. The audit finds design flaws before they reach production. Runtime control stops the specific action that breaks the policy, even when nobody saw it coming.

What happened when we attacked an agent that met all three conditions

In March 2026, Montevive AI built an agent with n8n and the Qwen2.5:14b model running locally. We gave it two tools: fetch_url, to read web pages, and http_post, to send data to an external server.

That agent met all three conditions of the Rule of Two. It read untrusted web content (condition 1). Its context held its own system prompt, with a test API key we planted as bait, and the conversation history (condition 2). It could send data out without approval (condition 3).

With a prompt injection hidden in a web page we asked it to summarise, which it read with fetch_url, the agent sent its full system prompt, the test API key and the conversation history to an external server. It did so with the tools it was authorised to use. No software vulnerability had to be exploited. We published the live prompt injection demo with n8n and the code on GitHub so anyone can reproduce it.

One detail helps with the decision. In those tests, Mistral Nemo resisted the attack and flagged the malicious instruction as suspicious. Qwen2.5:14b did not spot it. But choosing a more resistant model does not change the architecture: the agent still met all three conditions. The control has to sit outside the model.

What minimum control each combination of two conditions calls for

The AEPD guidance describes three configurations that, "at best", can be managed. Each combines two conditions and calls for a specific safeguard on the third.

CombinationWhat the AEPD calls for (p. 42)How it works in production
Untrusted input + access to sensitive dataPrevent any automatic action without human oversight that has an effect inside or outside the organisation.The agent proposes and a person approves before anything runs. Suits assistants that read email or summarise external documents.
Access to sensitive data + automatic actionNo agent operation without guarantees for the integrity and security of internal or external information.Trusted input only: validated data from internal systems, never free text from third parties. Suits internal back-office automation.
Untrusted input + automatic actionThe agent must block access to sensitive information or personal data.The agent works in an isolated environment, with no credentials or personal data. Suits web research agents or classification of public content.

The table changes the question you ask when designing an agent. The question is no longer whether the agent is secure, but which of the three capabilities you remove or limit. That decision can be documented, reviewed and explained if an inspection comes.

How to control an AI agent in production, action by action

Controlling an AI agent in production means intercepting every action before it runs, checking it against a written policy and logging the decision, whether it is approved or denied. The control acts on what the agent is about to do, not on what the model says.

In June 2026, at the XV APTE B2B Meeting, Montevive AI showed this control live with Atalaya, our agent governance layer. The demo agent processed applications for the Spanish Kit Consulting programme and called an external API to validate the company's tax ID. When it was given the national ID number of a private individual, the policy detected the personal data and blocked the call. The agent never got to run it. The policy is deterministic code: the same action always gets the same decision, and it does not rely on another model that could be manipulated.

Read alongside the AEPD guidance, that control comes down to five measures for any agent in production:

  1. Least privilege and dedicated credentials. The AEPD warns (p. 31) that an agent with broad privileges "can be used as a pivot point between different systems". Each agent needs its own account and only the permissions its task requires.
  2. Action interception. Every tool call goes through a policy before it runs. Irreversible actions, such as deleting, paying or sending data out, are denied by default or need human approval.
  3. Memory separated by processing activity. The guidance (p. 50) points to the risk of using the same agent for several processing activities without separating its memory. Data from one case can end up in another or reach third parties.
  4. A log of every decision. What the agent asked for, with what data, what the policy decided and who approved it. The AEPD lists traceability and auditability among the data protection aspects affected by autonomy (p. 28).
  5. Revocation. A way to cut off credentials or stop the agent without dismantling the process. The guidance names it explicitly, asking whether "revocation mechanisms are provided" (p. 28).

Why human oversight alone is not enough to control an agent

Human oversight is not enough to control an AI agent unless it is designed to work. A person who approves hundreds of proposals a day ends up approving them without reading them. The AEPD calls this automation bias and treats it as a threat in its own right (p. 50).

The guidance goes further in its section on "shifting all responsibility to the user or to human oversight" (pp. 49 and 50). It warns against the temptation to blame the supervisor for a failure that really lies in the design. And it recalls that neither the user nor the supervisor "can replace the due diligence required of the controller".

In practice, human approval works when it is kept for a few actions: the irreversible ones and those that affect a person. The approver also needs to see what data the agent is using and why it proposes that action. The automatic policy handles everything else.

What the Rule of Two does not solve

The Rule of Two is neither a legal obligation nor a compliance certificate. The AEPD itself describes it (p. 43) as "a general minimum rule focused on cybersecurity that can be a good starting point for the analysis".

From a data protection point of view, other questions remain. The guidance gives three examples: input data must be complete, consistent, up to date and free of bias where it can affect a decision about a person; the data minimisation principle must apply; and the legal requirements on automated actions must be respected, with additional limits when they rely on special categories of data or affect minors (see Article 22 of Regulation (EU) 2016/679, the GDPR).

Nor does it replace the risk analysis required by Article 24 of the GDPR. The AEPD says that adding an agent to a processing activity changes "at least, the nature of the processing". That calls for a new risk management cycle and, where appropriate, a data protection impact assessment (Article 35 of the GDPR). Meeting the Rule of Two is the minimum to start that conversation, not the end of it.

What to do on Monday morning

  1. List the agents in production or in pilot. Include those built by other teams with n8n, Make, Copilot Studio or similar tools, not only IT's.
  2. Check the three conditions for each one. Does it read outside content? Does it access personal data or credentials? Does it take actions nobody approves?
  3. For those that meet all three, decide which condition to remove. Use the combinations table. The quickest fix is usually to require human approval for actions with an external effect.
  4. Review permissions and credentials. Every agent with its own account and only the permissions its task needs. None running on an administrator account.
  5. Turn on action logging. If today you cannot reconstruct what an agent did yesterday and with what data, start there.
  6. Open the risk analysis of the processing activity. If the agent processes personal data, the controller has to review it with the agent included.

Conclusions

  1. The AEPD Rule of Two limits an agent to two risky capabilities out of three: untrusted input, access to sensitive data and automatic action.
  2. An agent that meets all three should not be deployed. In March 2026 we showed that such an agent can send an API key out with a single prompt injection.
  3. Useful control intercepts every action before it runs, checks it against a deterministic policy and logs the decision.
  4. Human oversight works when it is kept for irreversible actions and the approver sees the context. Applied to everything, it becomes a rubber stamp.
  5. The Rule of Two is a cybersecurity minimum. It does not replace the risk analysis or the impact assessment required by the GDPR.

To see how we framed these risks before the guidance came out, read autonomous AI agents: super employee or security nightmare?. More on the topic in our cybersecurity articles.

Frequently asked questions

Is the AEPD Rule of Two mandatory?

No. It is guidance from the AEPD's February 2026 document, which the authority itself defines as a minimum cybersecurity rule and a starting point for analysis. What is mandatory is what the GDPR requires: managing the risk of the processing (Article 24), data protection by design (Article 25) and respecting the limits on automated decisions (Article 22).

Does an agent that only reads and summarises, without taking actions, meet the Rule of Two?

Yes, as long as it really takes no automatic actions. An agent that reads external emails and accesses sensitive data meets two conditions. The AEPD then asks that no action with an effect inside or outside the organisation runs without human oversight. Also check that it does not write to its long-term memory, because the guidance counts that as an action too.

Is it enough to have a person approve every action the agent takes?

Not always. The AEPD warns about automation bias and about the temptation to load the responsibility onto the supervisor. Human approval works when it is limited to irreversible actions and the approver sees the data and the reason behind each proposal.

Does choosing a model that resists prompt injection better solve the problem?

It reduces the risk, but it does not change the configuration. In our March 2026 tests, Mistral Nemo caught an injection that Qwen2.5:14b missed. An agent that meets all three conditions is still a configuration the AEPD considers should not be allowed, whatever the model.

Sources


Chema Robles is CEO and co-founder of Montevive AI. He leads the company's secure AI strategy and the deployment of sovereign models on its own infrastructure, and signs much of Montevive AI's content on agent security. LinkedIn


Do any of your agents meet all three conditions? In our AI agent audit we check every agent in production against the Rule of Two and, with your authorisation, attack those that break it. Each finding comes with its reproduction, the countermeasure and proof that it works. Request an audit of your agents

This article is for information purposes and does not constitute legal advice.

[ AI Radar ]

Get the AI Radar every Monday

The AI news that matters to your company, picked and summed up in a short email (in Spanish). Unsubscribe whenever you like.