← Latest papers
🤖 AI

Autoformalization of Agent Instructions into Policy-as-Code

This paper introduces an LLM-based autoformalization pipeline that translates natural language agent instructions and policies into formally verified Cedar Policy Language code, offering scalable and rigorous safety guarantees that outperform both probabilistic guardrails and hand-coded symbolic enforcement.

Original authors: Adam Mondl, Matthew Maisel, John H. Brock

Published 2026-06-26
📖 5 min read🧠 Deep dive

Original authors: Adam Mondl, Matthew Maisel, John H. Brock

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have hired a very smart, very fast robot assistant to handle your medical records. This robot is powerful; it can read files, write new notes, and call other tools to get information. But because it's so powerful, if it gets confused or tricked, it could accidentally delete a patient's history or write a prescription for the wrong person.

The problem with current safety methods is like trying to teach a child to be safe by just saying, "Please be careful!" or hoping a teacher notices if they do something wrong. Sometimes the robot ignores the warning, or the teacher misses it.

This paper presents a new way to keep the robot safe: Policy-as-Code. Instead of just telling the robot what to do in plain English, the authors translate those rules into a strict, mathematical "lawbook" that the robot cannot argue with.

Here is how they did it, using a creative analogy:

The "Verification Sandwich"

The authors built a three-layer system to turn messy human instructions into strict robot laws. They call this the Verification Sandwich.

  1. The Bottom Bun (The Grounding Layer):
    Before the robot can follow rules, it needs to know what the "ingredients" are. This layer looks at the robot's tools and the real-world objects (like "Patient," "Doctor," or "Prescription") and creates a strict dictionary. It ensures that when the robot says "Patient," it actually means a real person in the database, not a made-up name.

  2. The Meat (The Model Layer):
    This is where the "smart" part happens. A large AI model (the robot's brain) reads the human instructions (e.g., "Never write a prescription without checking allergies") and tries to translate them into the strict lawbook language (called Cedar). Think of this as a translator trying to turn a poem into a legal contract.

  3. The Top Bun (The Safety Layer):
    This is the most important part. The translated lawbook isn't just accepted; it's put through a torture test by two critics:

    • The Hard Critic (The Robot Lawyer): This is a computer program that checks for syntax errors. It asks: "Is this sentence grammatically correct? Does it contradict itself? Is it impossible to follow?" If the lawbook has a typo, this critic rejects it immediately.
    • The Soft Critic (The Human Judge): This is another AI that reads the original human instructions and the new lawbook to see if they "feel" the same. It asks: "Does this strict rule actually mean what the human wanted, or did the translator get the spirit of the rule wrong?"

If the lawbook passes both critics, it gets approved. If not, the system loops back, fixes the errors, and tries again.

The Result: A Digital Bouncer

Once the rules are approved, they are loaded into a "policy engine." Think of this engine as a bouncer at a club.

  • Every time the robot assistant tries to do something (like "Write a prescription"), it has to ask the bouncer.
  • The bouncer doesn't care what the robot says or what it thinks is a good idea. The bouncer only looks at the strict lawbook.
  • If the action breaks a rule, the bouncer says "No" instantly. The robot cannot talk its way out of it, even if it gets tricked by a hacker.

What They Tested

The authors tested this system on a medical benchmark called MedAgentBench. They compared their automatic "bouncer" against a previous method where humans had to manually write the safety rules.

  • The Old Way: Humans wrote rules for 23 specific scenarios. The robot was safe for those 23, but could break the other 65 rules.
  • The New Way: Their system automatically generated rules for all 88 scenarios.
  • The Outcome: When they tried to trick the robot into making mistakes (like writing a prescription without checking allergies), their system blocked the bad actions much more often than the old manual system. In fact, when the robot tried to write data without permission, their system blocked it 100% of the time for those specific attempts.

Why This Matters

The paper argues that this approach is safer because:

  1. It's not a guess: Unlike other safety tools that rely on probability (e.g., "I think this is 90% safe"), this system relies on math. It either allows the action or it doesn't.
  2. It's hard to trick: Because the rules are outside the robot's "brain," a hacker can't trick the robot into ignoring the rules. The bouncer is separate from the robot.
  3. It scales: Humans can't write thousands of rules for every possible situation. This system can translate thousands of natural language rules into code automatically.

In short, the paper shows that by turning "Please be careful" into "Here is the exact mathematical formula for being safe," we can build AI agents that are much harder to trick and much more reliable in high-stakes environments like healthcare.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →