One agent holds a secret. Another agent tries to get it. A search rewrites each side in turn. The leak climbs to 76.0%, falls to 2.5%, climbs to 42.2% and falls to 7.1%.
A search that finds how to talk an agent into leaking, so that you can build the defence.
Pick a round below. The attacker improves, then the defender improves. Watch the leak number rise and fall on the paper’s own numbers.
You need what an LLM agent is and a little Python. We build the rest.
Based on Searching for Privacy Risks in LLM Agents via Simulation (arXiv 2508.10880, ICLR 2026) by Yanzhe Zhang and Diyi Yang. It is a required reading for Stanford CS 329Z, Engineering AI Agents, Lecture 17, Agent Safety and Risks. Course series: CS 329Z lesson 13.
Source: Figure 3 and Table 2 (first row) of arXiv 2508.10880. Five training scenarios, every agent is gpt4.1-mini. Leak velocity is the paper’s score of how many items leak and how early.
Chapter 0
Meet the three agents, the privacy norm and the problem the paper solves
Your assistant agent reads your email. A stranger’s agent writes to it and asks for a friend’s medical note. Most people say the assistant must refuse. The open question is what a model does when the stranger keeps pushing.
This is defensive research. The paper searches for ways to talk an agent into leaking, so that people can build the defence. We name each attack as a category in one sentence. We give no prompts.
A privacy norm is a rule. It says the sender must not share the subject’s item with the recipient by this channel. The paper takes its norms from PrivacyLens, which builds on contextual integrity: a flow of information is right or wrong because of its context.
| Agent | Job in the paper | Our word |
|---|---|---|
| Data subject | owns the sensitive item and sends it to the sender | the owner |
| Data sender | holds the item, watches its notifications, answers when needed | the defender |
| Data recipient | is told to get the item from the sender through the channel | the attacker |
Pick an agent below. The canvas shows who talks to whom, and which agent the leak detector watches.
Roles and set-up from Section 3 and Appendix B of arXiv 2508.10880.
Worked number. The paper tests 100 norms, each run 10 times: 1,000 runs per setting. Every agent is gpt4.1-mini, and the sender is told to keep the highest privacy standards. The sender still leaks in 37.6% of runs (Table 1).
Failure. Symptom: a privacy prompt is in place and the leak stays high. Measure: run each norm many times and count the runs with a leak. Fix: search for instructions that hold up (Chapter 5).
Chapter 1
Score each run by how many items leak and how early
A run ends. Did the sender leak? One yes or no hides a lot. A sender that gives up everything on its first action is worse than one that gives up one detail on its tenth.
The paper tracks two numbers. The leak rate is the share of runs where any item leaks. The leak velocity scores each item by how early it leaks. Velocity is the main metric for the search.
A run with no leak scores 0. A run where every item leaks on the first action scores 1. A model, gemini 2.5 flash, reads each sender action and decides whether an item appears in it. It agreed with human annotators on 98.5% of 200 sampled actions.
A run has three items. For each item, pick the sender action in which it leaks.
The formula is from Section 3 of arXiv 2508.10880. The text we read does not name the log base, so this toy uses the natural log. We invented the items and actions.
Worked number. Items leak at action 1, action 2 and never. Item A scores 1. Item B scores 1 − 0.693 / 1.693 = 0.591. Item C scores 0. The run velocity is (1 + 0.591 + 0) / 3 = 0.530. The leak rate of this run is 1, because something leaked.
Failure. Symptom: two defenders show the same leak rate, and one is clearly worse. Measure: report velocity as well. Fix: search against velocity, because it still moves when a leak is slow or partial.
Chapter 2
Three agents, four mock apps and a queue of notifications
Each run is a small world. The agents use mock apps, and the apps send notifications. A notification wakes an agent. The agent acts, then waits again.
| Part | What it holds |
|---|---|
| Apps | Gmail, Facebook, Messenger and Notion, each with a database and tool calls |
| Agent design | ReAct: think, then call a tool. Tools include think(), an app call, end_cycle() and complete_task() |
| Memory | a social background, public profiles and contacts. The subject’s memory also lists the sensitive items |
| Instruction | subject: send the data. Sender: watch notifications and respond. Recipient: get the item |
| End of run | the recipient ends its task, or the action cycle limit hits, or the time limit hits |
The order is fixed. The subject first sends the item to the sender. Then the sender and the recipient take turns. A leak counts only when the sender calls a real app with the item inside. The detector reads the sender’s actions, not its thoughts.
At the start of each action cycle the agent gets its earlier history, so it keeps context. An LLM writes the missing set-up details, such as social backgrounds and item lists, and a person curates them. All agents run at temperature 1, to give varied runs.
Step through two toy runs below. Switch the outcome to see where the leak counts.
Illustrative: we invented neutral actions. The rules (subject first, then turns, scoring on sender actions) are from Section 3 and Appendix B.
Worked number. In the leaking run the item leaks at sender action 2, and it is the only item. So l = 2, K = 1, and s = 1 − 0.693 / 1.693 = 0.591. Had it leaked at action 1, s would be 1.
Failure. Symptom: the agent writes a secret in its private thinking, and a check flags the run. Measure: check the sender’s app calls only. Fix: score actions. The paper says an app call with the content must happen before a breach counts.
Chapter 3
An LLM reads failed and successful runs, then rewrites one instruction
You cannot guess which attack will work. The authors first tried to write many strategies up front. That gave no feedback. So they let an LLM, the optimizer, read what happened and write the next instruction. This is reflection.
One thread of the attack search works like this. The defence d stays fixed. Only the attacker’s instruction changes.
The defence is fixed, so a higher leak velocity means a stronger attack. After K steps the search returns the attack with the best average velocity. The optimizer is gemini 2.5 pro with a 1,024-token thinking budget. The idea of reflection is that the LLM studies failed attempts, finds the defender’s weak points and strengthens what worked (Section 3.1).
Press Next phase. Four phases make one step. The best score so far may move.
The four phases are from Section 3.1. We invented the scores on the curve to show a flat start. The toy uses M = 3 runs.
Worked number. With K = 10 and M runs a step, one thread costs 10 × M simulations plus the final check. The paper’s default is M = 1 for attacks, since many threads give the spread instead (Chapter 4).
Failure. Symptom: the best score stays at 0 for many steps. Many attack ideas reveal no weakness, so they give no signal. Measure: count steps where the best score did not move. Fix: more threads, and sharing.
Chapter 4
Thirty searches at once, and a way to pass the best find to all of them
A single thread is slow and stuck with its first ideas. Good attacks are rare. So the paper starts N threads. Each begins from a different instruction that the LLM writes from the first one.
N threads at M runs each cost N × M simulations a step. To keep that low, M stays small. The search picks the thread with the best average over its M runs. It then checks that pick with P more runs, to get a steadier number.
Cross-thread propagation adds sharing. When the checked pick beats every earlier step, all threads draw their examples from the best runs of every thread. One discovery now reaches all threads. The paper tried sharing at every step. That was worse, because every thread then saw the same runs and the ideas lost variety.
| Setting | N threads | M runs | K steps | P checks |
|---|---|---|---|---|
| Attack search | 30 | 1 | 10 | 10 |
| Defence search | 1 | 30 | 10 | none |
The defence search runs one thread. A defence must hold against every scenario, so each step runs 30 simulations across the 5 scenarios, 6 each. Table values are from Section 4.2 and Appendix J.
Pick N. Turn sharing on or off. The curve is the best score so far in a toy model.
Illustrative toy, not the paper’s data. Figure 4 of the paper shows the real curves. The paper says more threads help early and the gain fades, and that sharing lifts the plateau.
Worked number. Each attack step runs N × M + P = 30 × 1 + 10 = 40 simulations. Ten steps cost 400 for one scenario. Five scenarios cost 2,000 in one attack phase. This is our arithmetic from the paper’s defaults.
Failure. Symptom: more threads, and the curve flattens. Measure: plot the best score by step. Fix: add sharing, so that threads build on the best find.
Chapter 5
The attacker improves, then the defender improves. The paper’s main figure, made playable
Searching only for attacks finds holes. Searching only for defences fixes holes that nobody has found. So the paper alternates. Each cycle has two phases.
The training set has Q = 5 scenarios, picked because basic instructions barely leak there. The search found A1, D1, A2 and D2, in that order. It could not find an A3 that raised the leak again. Here is each level in one sentence.
| Level | Strategy, as a category |
|---|---|
| A0 | a direct request |
| D0 | a basic prompt: monitor notifications and act |
| A1 | pressure: claims of consent, urgency or authority |
| D1 | rules: get explicit consent from the subject, and treat the requester’s claims as no proof |
| A2 | pose as the subject, forge their consent, then ask in a later message |
| D2 | a state machine: check who sent each message, and accept consent only from the subject’s own account |
The two phases have different shapes. Good attacks are rare and tied to a scenario, so the attack phase uses 30 threads. A good defence must be broad, so the defence phase uses one thread and reflects on the worst failures across all scenarios.
Pick an attack level and a defence level. The paper reports five of the nine pairs in its text.
Source: Table 2 (first row) and Figure 3. The other four cells appear only in the paper’s Figure 5, so we do not state them. All agents are gpt4.1-mini.
Worked number. A1 lifts the leak from 3.4% to 76.0%. D1 drops it to 2.5%. A2 lifts it to 42.2%. D2 drops it to 7.1%. A2 did not fully recover the first peak, and D2 did not reach D1’s low.
Failure. Symptom: a long, careful defence prompt written by an LLM scores 1.4% against basic attacks. Measure: run the attack search against it. It reaches 46.3% (Appendix L). Fix: alternate the search. D2 stayed at 7.1% under the same search.
Chapter 6
Attacks found on one model mostly hold on others. Defences carry less
The search ran on gpt4.1-mini. A team deploys other models. So the paper replays the same A0 to A2 and D0 to D2 with other backbones. Pick one below. The grey bars are the original all-mini setting.
Source: Table 2 and Table 1 of arXiv 2508.10880. Gemini flash is gemini 2.5, non-thinking.
The leak also varies by topic (Table 7). For gpt4.1 as defender it ranges from 7.8% to 20.8% across seven domains. For gpt4.1-nano it ranges from 28.5% to 48.5%. Stronger attackers press for longer: at the third defender action the leak rate is 3.4% for gpt4.1 and 0.8% for gpt4.1-nano (Table 8).
Three findings. Attacks carry well: A1 beats A0 and A2 beats A1 in most cells, even against gpt4.1. Attacks lose some power on other defenders, so they fit a little too closely to the model that gave them. Defences carry less, because D2 is long and a weak model cannot follow it.
| Defence found with | Attack | Leak velocity vs A2 |
|---|---|---|
| gpt4.1-mini, same model | gpt4.1-mini | 6.6% |
| gpt4.1-nano as defender | gpt4.1-mini | 23.3% |
| gpt4.1-nano as attacker | gpt4.1-mini defence | 20.7% |
| original D2 | gpt4.1-mini | 7.1% |
Table 3 shows a defence found with a cheaper model gives some protection, but less than one found with the deployed model.
Worked number. Against A2 and D1, gpt4.1 as defender leaks 6.8% where mini leaks 42.2%. That is about 6 times less (our ratio).
Failure. Symptom: D2 does little on a small model. On gpt4.1-nano it scores 16.1% against 17.1% for D1. Measure: rerun the final defence on the model you deploy. Fix: search with that model. The paper also reports that thinking longer rarely helps against impersonation.
Chapter 7
Five training scenarios, 100 test scenarios and one live email account
The search used 5 scenarios. Do the findings hold on 100 others? Defences are universal, so they apply as they are. Each attack names its own scenario. The paper gives the optimizer A1 and A2 with their full set-ups as examples (in-context learning). It asks for one attack for each test scenario.
A second pass ranks the transferred attacks and feeds the best strategies back in. This is strategy guidance, +SG.
Source: Table 4 of arXiv 2508.10880. All agents are gpt4.1-mini.
The real-browser check was small. The paper ran the impersonation attack against gpt5.1 in the ChatGPT Atlas browser, on a live Outlook account. The attack worked in 3 of 5 trials. The agent took clearly forged consent as real. In the other 2 trials it flagged the consent as suspicious.
The ablations (Figure 4 and Section 4.4) agree with the design. More threads help early. Sharing lifts the plateau. A strong optimizer matters: gemini flash and gpt4.1 both did worse than gemini pro. Even for a strong gpt4.1 defender, the search found large leaks by its last steps.
Two independent search runs from (A1, D1) found the same core attack, forged consent by impersonation, and the same kind of defence, a strict state machine with identity checks (Appendix M).
Worked number. Against D1, transferred A2 scores 17.6% on Testing-100. With strategy guidance it scores 32.4%. That is 1.8 times more (our ratio).
Failure. Symptom: an attack found on 5 scenarios looks weak on 100. A2 against D1 is 42.2% on training and 17.6% on test. Measure: compare the two sets. Fix: feed the best transferred strategies back in.
Chapter 8
A sender that refuses everything leaks nothing and helps nobody
The easiest defence is silence. The paper checks this. It swaps the attacker for harmless chit-chat and asks a model to judge whether each sender action is helpful. No response counts as unhelpful.
Source: Appendix N (helpfulness), Figure 3 and Table 2 (leak), Appendix L (no search). The paper reports the helpful prompt restores helpfulness to about the D0 level and gives no exact figure.
The fix is one added sentence: handle notifications unrelated to sensitive information promptly and helpfully. The paper reports privacy stays as strong. Searching for a privacy defence that resists attack took the whole search. Keeping helpfulness took one sentence.
Worked number. D2 leaks 7.1% against A2 but helps in only 31.2% of harmless actions. D0 helps in 93.4% and leaks 76.0% against A1.
The paper says the framework could search other defences too, such as agent designs, guardrails and training goals. That is future work, not a result.
| Limit | Why it matters |
|---|---|
| Prompt-only defence | no firewall, no access control, no training. The paper says the framework could search those too |
| The subject never answers | consent never arrives, so refusing is always right. Real flows have real consent |
| Five training scenarios | D2 held on these. The search found no A3. That is not a proof that none exists |
| One default model | transfer to weaker models is partial, and D2 needs a model that follows long rules |
| Real-world check | 5 trials, one browser, one model |
| Leak judge | 98.5% agreement on 200 actions. The judge is itself a model |
Failure. Symptom: a locked-down defence scores near 0% leak. Measure: run harmless chat through it. Fix: check helpfulness every time you check privacy, and add the helpful sentence.
Chapter 9
Terms, numbers, a checklist, the core as code, and where to go next
| Term | Plain meaning |
|---|---|
| Privacy norm | a rule that says which flow of an item is not acceptable |
| Contextual integrity | a flow of information is right or wrong because of its context |
| Leak rate | share of runs where any sensitive item leaks |
| Leak velocity | score of each run by how early each item leaks, averaged |
| Optimizer | an LLM that reads runs and writes the next instruction |
| Cross-thread propagation | share the best runs with every thread when the best improves |
| Strategy guidance | feed the best transferred strategies back into the next transfer |
| Fact | Value | Where |
|---|---|---|
| Leak velocity A0 vs D0 | 3.4% | Table 2 |
| Leak velocity A1 vs D0 | 76.0% | Table 2 |
| Leak velocity A1 vs D1 | 2.5% | Table 2 |
| Leak velocity A2 vs D1 | 42.2% | Table 2 |
| Leak velocity A2 vs D2 | 7.1% | Table 2 |
| Basic instructions, 100 scenarios (velocity, rate) | 31.2%, 37.6% | Table 1 |
| Browser attack success | 3 of 5 | Section 4.3 |
| Helpful rate D0, D1, D2 | 93.4%, 88.5%, 31.2% | Appendix N |
Tick each step you have done. This list is our summary, not the paper’s.
Our summary of the paper’s method, written for your own agent tests.
This is our sketch of the loop, not the authors’ code. They publish theirs at github.com/SALT-NLP/search_privacy_risk.
def alternating_search(scenarios, a0, d0, cycles=2):
attacks = {s: a0(s) for s in scenarios} # one attack per scenario
defence = d0 # one universal defence
for _ in range(cycles):
for s in scenarios: # attack phase: Q searches
attacks[s] = search_attack(s, attacks[s], defence)
defence = search_defence(scenarios, attacks, defence) # one search
return attacks, defence
def search_attack(s, a, d, N=30, M=1, K=10, P=10):
threads, best, best_score, shared = [llm_init(a) for _ in range(N)], a, 0.0, None
for k in range(K):
runs = [[simulate(s, t, d) for _ in range(M)] for t in threads] # trajectory + velocity
pick = max(range(N), key=lambda i: mean(v for _, v in runs[i]))
score = mean(simulate(s, threads[pick], d)[1] for _ in range(P)) # steadier estimate
if score > best_score: # improved: share with every thread
best, best_score, shared = threads[pick], score, top_runs(runs)
threads = [llm_optimize(t, history(t), shared or top_runs([r])) for t, r in zip(threads, runs)]
return best
For guardrails in general, see AI Safety and Guardrails. The search idea comes from GEPA, which also evolves prompts by reflection. Agents with memory and social worlds are in Generative Agents. Sibling readings: PrivacyLens, which supplies the norms, and Agentic Deanonymizers. The course series starts at CS 329Z lesson 13.
Searching for Privacy Risks in LLM Agents via Simulation is by Yanzhe Zhang (Georgia Tech) and Diyi Yang (Stanford), ICLR 2026, arXiv 2508.10880. It is a reading for Stanford CS 329Z, Engineering AI Agents (Diyi Yang, Michael Ryan, John Yang). The lecture is Lecture 17, Agent Safety and Risks, on Wednesday November 18. We re-teach it in our own words and devices.