Lion Cipher Lab

Gate an AI agent's tool calls with an OPA/Rego allow-list: deny by default, constrain the arguments, and unit-test every denial

Why it matters

An AI agent turns text into actions: it reads a file, sends a payment, runs a query. The model's decision about which action to take can be wrong, can be steered by text hidden in a web page or document it read, or can simply be sloppy. OWASP calls the result Excessive Agency: damaging actions performed because the system let the model do more than it needed to. Asking the model to behave is not a control. A control is a separate piece of code, outside the model, that looks at each proposed call and says yes or no from rules a human wrote and tested. Open Policy Agent (OPA) and its policy…

What you'll learn

Steps in this lab

  1. Why the gate must live outside the model
  2. Install OPA and describe a tool call as input
  3. Write the policy: deny by default, collect reasons
  4. Evaluate real calls with opa eval and read the reasons
  5. Write the tests: allows, denials and the boundary
  6. Break a boundary on purpose and watch a test catch it
  7. Measure how much of the policy your tests touch
  8. Wire the policy behind a fail-closed enforcement point
  9. What this gate does not do
  10. Clean up

Open the full interactive lab →

Keep learning