Loophole: Adversarial Agents To Stress Test Your Morality

Brendan Rappazzo, Morgan Stanley17:00 · Sept 2026 · 3,264 views
Thumbnail for Loophole: Adversarial Agents To Stress Test Your Morality Watch on YouTube
TL;DR
  1. 1

    Loophole turns a user's moral principles into a legal code and uses adversarial agents to find immoral acts that are legal and moral acts that are illegal.

  2. 2

    The system uses a judging agent to patch imperfect translations automatically or ask the user to resolve genuine gaps and contradictions.

  3. 3

    The same approach can generate chatbot constitutions, compare personal rules with company contracts, and simulate how legislators or voters might respond to bills.

Summary

Brendan Rappazzo presents Loophole, an open-source project that turns plain-language moral principles into a formal legal system. One agent writes the code, while two others generate synthetic cases from opposite directions. A loophole is something immoral but legal under the code. An overreach is something moral but illegal. A judge agent decides whether to patch the code or ask the user to clarify an underspecified moral rule. Rappazzo connects this process to common law, where case law handles boundaries that are difficult to state in advance. He then describes applications beyond the game: generating system prompts for customer-facing agents, checking personal rules against company terms of service, creating decentralized contracts, and simulating the US Senate. In his Senate experiment, Claude inferred moral systems from public information about senators, then tested and revised a Medicare bill until its simulated vote changed from 50-50 to 52 votes. He also describes testing bills against 500 synthetic personas per state.

Key ideas
00:12

Loophole turns moral principles into a game of adversarial legal reasoning

Rappazzo describes Loophole as an open-source game built on adversarial agents. The user writes moral principles in natural language. One agent codifies them into a legal system, then two other agents search for contradictions. One looks for loopholes, meaning actions that are immoral but legal under the user's rules. The other looks for overreach, meaning actions that are moral but illegal. The project began as a way to stress test a person's own moral code rather than as work for Morgan Stanley, where Rappazzo is a machine learning researcher.

00:54

The project began with uncertainty about how DNA might be used

Rappazzo traces the idea to sending his DNA to 23andMe for ancestry testing. He later heard about DNA samples being used to solve crimes, forensic investigations, and cold cases. He had opted out because he was worried about how his DNA could be used, but he realized that some specific cases might be acceptable to him. He could answer case by case if someone presented the situation, yet listing every possible case was cognitively impractical. That gap led him to think about a system that could enumerate and test the boundaries of his beliefs.

01:56

Legal systems have the same translation problem as personal morality

Rappazzo describes a legal system as an attempt to codify society's moral beliefs. The difficult part is translating nuanced values into general rules. People often choose rules that are too broad because precise translation is hard, which creates strange corner cases. He connects this problem to English common law, where case law carries much of the nuance because judges interpret and apply rules to particular situations. Loophole generates synthetic case law to expose boundaries that a first draft of a moral code misses.

04:00

The judge agent separates fixable drafting errors from gaps in the user's morals

The system operates as a loop. A drafting agent produces a detailed legal code, a loophole agent searches for immoral but legal cases, and an overreach agent searches for moral but illegal cases. A judge reviews the user's morals, the code, and the generated cases. If the issue is an imperfect translation, the judge can automatically patch the code. If the problem reveals an underspecified or contradictory moral rule, the system raises it to the user for a decision. Rappazzo's example of a loophole involves an insurance company training a model on artifacts derived from DNA rather than DNA itself, which the code treats as immoral but legal.

07:02

Some moral questions require the user to decide rather than accept an automatic patch

Rappazzo gives an overreach that the judge could not resolve automatically. A person submits DNA for genetic research, and the researcher discovers a rare but treatable genetic disorder. Under the example moral code, disclosing the disease to the person is not allowed, even though many people might consider disclosure moral. Because the system could not infer the intended boundary, it raised the case to Rappazzo for judgment. His decision would produce a patch to the legal system. The example shows that the system can surface an unresolved moral question rather than hide it inside an automated correction.

08:05

The same loop can generate constitutions for customer-facing agents

Rappazzo's first extension moves from personal legal codes to chatbot behavior. A company can write what a customer-facing agent should and should not discuss, along with the moral rules it should follow. An agent then drafts a codified system prompt. Adversarial agents try to make the chatbot discuss forbidden subjects or refuse subjects it should address. The resulting process is similar to his legal game, but its output is a system prompt for an agent. Rappazzo frames this as an automated way to build and test a constitution for a chatbot.

09:07

Personal legal codes could expose conflicts with company contracts

A second extension applies the method to privacy rules and contracts. A person could specify how they want their data handled, convert those preferences into a codified legal system, and compare it with a company's terms of service. If Apple released new terms, the system could generate cases where the company's behavior differs from the user's rules. The user might not be able to negotiate with a large company, but the comparison could show the practical consequences of the contract before they agree. Rappazzo also imagines two parties creating and stress testing their own codes before making a contract across countries or without a central authority.

12:17

The Senate simulator revises bills against inferred moral systems

Rappazzo built a US Senate branch that uses Claude to infer a moral system for each current senator from voting history and other public information. Those systems are converted into legal codes. A proposed bill can then be run through the codes to estimate how each senator might vote and to generate reasons for the votes. In one Medicare experiment, the bill initially received a 50-50 simulated vote. The system changed the bill's language while preserving its core tenets and found a version that received 52 votes. It could rank possible changes, leaving the user to choose the trade-offs.

14:25

Synthetic voter personas extend bill testing beyond legislators

Rappazzo also describes testing bills against synthetic constituents. He used NVIDIA's USA personas dataset and selected 500 personas per state, intending them to represent each state's population. For each persona, the process drafted moral principles and a legal contract, then compared a bill with those rules. The system could measure how much a state's personas agreed with a bill and hill climb the bill toward greater agreement. Rappazzo presents this as an exploratory direction for measuring how legislation relates to constituents' stated or inferred moral preferences, while acknowledging privacy and logistical issues around government applications.

"So you specify your morals, one agent codifies that into a legal system and then these two adversarial agents try to find contradictions in your morals."00:12
Who should watch
  • You are designing an agent that needs a precise system prompt and want adversarial tests for both unwanted disclosures and unwanted refusals.
  • You are building contracts, privacy policies, or terms-of-service checks and need to find disagreements before accepting a rule.
  • You are interested in using language models to test legislation against simulated legislators or constituent personas.