All writing
  • AI Agents
  • Privacy
  • Reinforcement Learning

Defense in the Loop: Why Privacy Has to Happen Mid-Task, Not at the Exit

If a multi-agent system leaks most of its sensitive data through internal channels during execution, then a privacy check bolted onto the final output is guarding the wrong door. A 2026 paper makes the fix precise: Contextualized Defense Instructing (CDI, arXiv 2603.02983) puts an instructor model inside the agent loop that generates step-specific, context-aware privacy guidance as the agent runs — shaping actions rather than vetoing outputs — and trains that instructor with reinforcement learning by turning privacy-violation trajectories into learning environments. It reports a 94.2% privacy / 80.6% helpfulness balance, beating static prompt-and-guard baselines. Here's why the defense belongs in the loop, why training it is the real work, and why that's a layer Southeast Asia can own.

We just argued, in the privacy leak is between the agents, that the dangerous privacy failures in agent systems happen in transit — in the inter-agent messages and tool arguments that flow while the system works, not in the polished answer it finally returns. That post measured the problem. This one is about the shape of the fix, and the fix has an awkward implication a lot of teams haven’t absorbed: if the leak happens mid-execution, a defense that runs at the exit is guarding the wrong door.

The standard privacy posture is exactly that exit guard. You let the agent run however it runs, and then you filter, redact, or block the final output before it reaches the user. It’s the privacy equivalent of proofreading a letter after it’s been dictated to a roomful of people. The sensitive disclosure already happened — to the worker agent, to the tool, to the shared scratchpad. Scrubbing the envelope doesn’t recall the conversation.

Two places you can stand in the loop

A 2026 paper, Contextualized Privacy Defense for LLM Agents (arXiv 2603.02983), is useful precisely because it refuses to treat “privacy defense” as one undifferentiated thing. It formalizes baseline defenses and its own method as distinct intervention points in a canonical agent loop — and once you see privacy that way, the design space gets clear.

The paper’s framing of the status quo is blunt: “most prior approaches rely on static or passive defenses, such as prompting and guarding,” and “these paradigms are insufficient for supporting contextual, proactive privacy decisions in multi-step agent execution.” Unpack those two:

  • Prompting is the system-prompt approach — “be careful with personal data” baked in up front. It’s static. It can’t reason about a specific hand-off that’s about to over-share, because it fired once, at the start, with no view of the step in front of it.
  • Guarding is the gate at a boundary — a classifier that inspects an action or an output and vetoes it. It’s reactive and binary: it sees a disclosure and says no. But a veto at a boundary is late (the decision to over-share was already made) and crude (it can block, but it can’t fix — it has no way to say “share less,” only “don’t”).

Both live at the edges of the loop. The paper’s argument is that the privacy-relevant decisions live inside it — at each step, in context — and so the defense has to live there too.

What CDI actually does

The method is Contextualized Defense Instructing (CDI): “an instructor model generates step-specific, context-aware privacy guidance during execution, proactively shaping actions rather than merely constraining or vetoing them.” That sentence is the whole idea, and the word that matters is shaping.

Instead of a gate that watches the output, CDI runs an instructor model alongside the agent, and at each step it issues guidance tailored to what the agent is about to do right now — given this task, this context, this hand-off, share these fields and not those, frame the request this way. It’s the difference between a bouncer who turns people away at the door and a coach in the agent’s ear the whole time. The bouncer can only react to what already walked up; the coach changes the play before it runs. Because the guidance is generated per step and per context, it can do the thing a static prompt and a binary guard both can’t: preserve the usefulness of the action while removing the over-disclosure, rather than trading one for the other.

That trade-off is exactly what the paper measures, in a unified simulation framework that compares the intervention points head to head. The result: CDI “consistently achieves a better balance between privacy preservation (94.2%) and helpfulness (80.6%) than baselines, with superior robustness to adversarial conditions and generalization.” The number that matters isn’t either figure alone — it’s that they hold together. The persistent failure of privacy tooling is that cranking up protection guts usefulness; the system gets so cautious it stops being able to do its job. A defense that keeps helpfulness at 80.6% while holding privacy at 94.2% is claiming it can be careful without being useless. Holding both is the whole game, and it’s the same balance we keep insisting verification has to strike everywhere in the agent stack.

The real work is training the instructor

Here’s the part that should interest anyone who’s been reading us on how agents actually get good. An instructor model that gives smart, step-specific privacy advice is not something you can simply prompt into existence — it has to learn what good guidance looks like. CDI’s answer is the interesting half of the paper: it’s “paired with an experience-driven optimization framework that trains the instructor via reinforcement learning (RL), where we convert failure trajectories with privacy violations into learning environments.”

Read that slowly, because it’s a beautiful move. The system’s own privacy failures — the runs where sensitive data leaked — become the training signal. Each violation is turned into an environment the instructor practices against, learning to recognize the moment before the leak and steer around it. This is precisely the pattern we traced in how agents learn to code: you don’t write the rules by hand, you let the agent practice in an environment that can tell it when it got something wrong, and the capability accrues from the practice. CDI applies that recipe to privacy. The defense isn’t a fixed rulebook; it’s a learned policy that gets sharper every time the system would have leaked.

And notice where that puts the defense in the architecture. It’s not a wrapper around the loop. It’s a participant in the loop — an intervention point, trained by the loop’s own experience, acting at each step. Which is the through-line of everything we write.

Defense is a loop component, not a wrapper

Step back and the two posts compose into a single claim. AgentLeak showed the leak is a property of the loop’s internal traffic, not its output. CDI shows the defense has to be a property of the loop too — a step-level participant, not a perimeter. Privacy, like reliability and like correctness, turns out to be something you engineer into the feedback cycle, not something you bolt onto its edges.

This reframes what a “privacy guard” even is. The instructor model is doing something close to what we described in who judges the judge: a model whose job is to evaluate and steer another model’s behavior, mid-flight, against a standard. And it slots into the canonical agent loop pattern as a named stage — plan, act, be instructed on privacy, observe — rather than as an afterthought. Once you accept that the loop is the unit of the system, it follows that every cross-cutting concern you care about, privacy included, has to be expressed as a stage or a signal within the loop. The exit guard was always a category error; CDI is what the corrected version looks like.

Why this favors Southeast Asia

The encouraging part, again, is what this kind of defense runs on. An instructor model trained to give context-aware privacy guidance is small relative to the frontier model it supervises, and the thing that makes it good is not scale — it’s a well-built learning environment full of the right failure trajectories. That’s a judgment-and-data problem, not a compute problem, and it’s exactly the environment-building skill we keep arguing the region is positioned to own.

Better still, the learning environments that make a privacy instructor good are inherently local. What counts as an over-disclosure depends on the jurisdiction, the language, the sector, and the specific notion of sensitive data that a Cambodian bank, an ASEAN health system, or a regional government actually operates under. A frontier lab has no failure trajectories from those settings and little reason to gather them. A team close to the problem does — and can turn its own near-misses into the environment that trains an instructor no generic guard will match on that domain. The frontier model in the middle stays a commodity; the privacy policy learned in the loop, from local data, is the defensible layer.

The leak was in the loop. So is the fix. Build the instructor, train it on the failures you can see, and the privacy guarantee stops being a filter you hope holds and becomes a behavior the system learned.

If your agents handle sensitive data and your only defense is a filter at the end — let’s talk about moving it into the loop.