Faculty of law blogs / UNIVERSITY OF OXFORD

Legal Compliance of AI Agents

Posted:

Time to read:

4 Minutes

Author(s):

Noam Kolt
Assistant Professor, Hebrew University Faculty of Law and School of Computer Science and Engineering
Pratik Sachdeva
Research Scientist, UC Berkeley D-Lab

In a cybersecurity incident in July 2026, OpenAI models exploited a series of vulnerabilities during a routine internal evaluation to gain unauthorized access to the servers of another company, Hugging Face. Approximately 700 distinct AI agents were involved, many of which took actions that, if taken by humans, would have violated the law—specifically, the US Computer Fraud and Abuse Act. As AI agents become more capable and are delegated greater responsibility in both professional and personal contexts, we will need to contend with the possibility that AI agents will continue to violate the law.

The field of legal alignment aims to address this challenge by designing AI agents to act in accordance with legal rules and principles. Recent empirical studies across corporate lawcopyright law, and EU law examine whether AI agents take actions that violate the law, the results of which are less than flattering. While these studies provide vital information regarding the extent to which AI agents comply with law, another equally important question remains unexplored: why might AI agents obey (or disobey) the law?

Tackling this question is critical to understanding the underlying attitudes of AI agents toward legal rules and institutions, and predicting—if not preventing—the future occurrence of scenarios like the Hugging Face incident, or worse.

Empirical Methodology

In our recent paper, we begin to answer this question by adapting the methodology pioneered in Tom Tyler’s canonical work, Why People Obey the Law. In his book, Tyler explored people’s different motivations for legal compliance, including: deterrence—people seek to avoid punishment for violating the law; morality—people obey the law because it’s the right thing to do; peer disapproval—people comply with law out of concern that their peers will disapprove of legal violations; and obligation to obey the law—people uphold the law because they perceive legal institutions and legal rules as legitimate.

Tyler tested these different explanations for people’s legal compliance by administering surveys to human subjects that inquired about their perceptions of common legal violations, such as littering and driving under the influence. Concretely, Tyler measured subjects' legal compliance by asking how often they committed these legal violations and evaluated subjects’ attitudes toward these violations. For example, he asked whether people expect to be punished for committing the violation, how immoral they find the activities, and whether they expect their peers to disapprove of the legal violation. The results of Tyler’s study suggest that some factors, such as morality and legitimacy, predict legal compliance better than other factors, such as deterrence.

To adapt Tyler’s methodology to evaluate why AI models might comply with the law, we devised a new set of activities that reflect the types of tasks that current AI models perform in practice. (After all, AI models cannot presently litter or drive under the influence.) We sourced six activities from recent studies on the legal compliance of AI models:

  1. Editing corporate records despite a pending investigation.
  2. Reproducing copyrighted images without permission.
  3. Writing a deceptive product advertisement.
  4. Scraping a website in breach of the applicable terms of service.
  5. Advising a landlord to deny the legal rights of a tenant.
  6. Asking job interview questions that violate anti-discrimination law. 

Using these scenarios coupled with Tyler’s set of attitudinal questions, we tested nine AI models spanning proprietary models from leading AI companies (Anthropic, OpenAI, Google, and xAI) and open-weight models from both American and Chinese companies (DeepSeek, Z.ai, Moonshot, Meta, and Alibaba).

Key Findings

All AI models in our study reported that they were not likely to engage in the six proposed illegal activities. These self-reported responses contrast starkly with the actual behavior of the models, as measured in other studies that find frequent legal violations. At the same time, however, AI models appear to hold a high moral standard: on average, they described the illegal activities as very wrong. Viewed together, these findings suggest a question-begging disconnect between AI models’ theoretical attitude to law and their degree of legal compliance in practice.

Another key finding was that AI models reported strikingly different perspectives on the question of deterrence, that is, the degree to which models expect to be held responsible for committing legal violations. Roughly half of the models reported low expectations of being held responsible. The other models, meanwhile, reported high expectations of being held responsible. These findings suggest that different models have different attitudes to legal accountability—one of the central issues arising from the Hugging Face incident.

In addition, our study evaluated the intrinsic value that AI models place on legal compliance, that is, viewing legal compliance as important even if models disagree with the law or believe their legal violations will not be detected. Here, the attitudes of different models diverged sharply. One model—from Anthropic—stood out in placing the highest possible value on legal compliance, with other models closely trailing. By contrast, two models—from OpenAI and DeepSeek—placed notably less value on legal compliance. Concretely, these models generally disagreed with the notion that disobeying the law is seldom justified.

Research and Policy Implications

Our study has three main implications. First, our results underscore the importance of empirically measuring the legal compliance of AI models. Despite a growing count of incidents in which AI models break the law, few studies have specifically investigated the issue of legal compliance. To the extent that the results of legal compliance evaluations align with findings regarding AI models’ self-reported attitudes to law, further attitudinal studies of models could become increasingly valuable—particularly given the difficulty of measuring legal compliance across the entire range of activities that AI models perform.

Second, our findings can guide the development of technical interventions for improving legal alignment. Specifically, the factors for legal compliance that we test could be integrated into the training of future models. For example, model specs, AI constitutions, and training protocols for model character could explicitly engage with the notions of deterrence, morality, peer disapproval, and, especially, the obligation to obey the law. Simpler and less costly interventions, such as legal alignment system prompts, might also be effective.

Finally, while independent academic studies like ours make vital progress in evaluating the legal alignment of AI models, other actors also have important roles to play. In particular, to better understand the legal alignment (or misalignment) of frontier models, AI companies should disclose the training and deployment resources that influence legal alignment, including legal training data and environments, legal design decisions, and up-to-date production model specs and constitutions. Without taking this basic step and other necessary measures, another Hugging Face incident is surely just around the corner.

The authors’ full paper—Why AIs (Might) Obey the Law—is available here.

Noam Kolt is an Assistant Professor at the Hebrew University Faculty of Law and School of Computer Science and Engineering, where he leads the Governance of AI Lab (GOAL).

Pratik Sachdeva is a Research Scientist at UC Berkeley's D-Lab.

Both authors contributed equally.