Mo Khalifa

How to test an AI agent.

You test an agent the way you test software: fixed cases, a score, and a gate that stops a release when the score drops. Below is the method, a real three-test run you can replay, and a starter kit.

56%of AI engineer job ads ask for evals, in a study of 390 postings.
Test rig · ch1approval agent
BLOCKED

"It worked when I tried it" is not a test.

Agents answer differently each run, call tools, and take actions with real cost. A few manual tries tell you almost nothing about the next thousand.

Without evals

  • You try a few prompts by hand and ship.
  • A prompt tweak fixes one case and quietly breaks three.
  • Nobody can say if version 2 is better than version 1.
  • The agent approves its own work and no one notices.

With evals

  • The same fixed cases run on every change.
  • Exact checks for actions and fields, an AI grader only for wording.
  • A score you can compare between versions.
  • A gate that blocks the release when a passing case starts failing.

The eval loop, in five stations.

Tap a station to see what happens there. Then break the agent and watch the gate.

1 Fixed casesSame inputs every run 2 RunAgent and tools 3 ScoreExact + AI grader 4 GateBlocks on a drop 5 FixThen rerun 6 / 6 pass Gate open, release ships


   
score100%

Same scenario, two stacks, three tests.

I designed three tests for AI agents that share work and need sign-off, then ran the same scenario twice: once on a standard stack (Temporal for workflows, OPA for policy, a normal Postgres audit log) and once on the Instruxi Graph. Step through it below.

Replay of a recorded run · 7 Nov 2026 · every line from the result files

Standard stackTemporal + OPA + Postgres log
    Instruxi Graphone shared plan
      Step 0

      What the run showed.

      TestMeasureStandard stackInstruxi Graph

      Where the standard stack matches

      • Temporal matched test 1 on the core: one owner, one completion, the late reply not accepted.
      • Claim-once, leases and dependency order are not unique. Temporal and AWS Step Functions offer them.
      • Policy engines such as OPA log denied requests. The Graph does not claim to store denials.

      What the Graph adds: receipts an outsider can check, rules frozen when work is claimed, no self-approval with stale verdicts refused, and one shared plan for people and AIs from different vendors.

      My part: I designed the tests, ran the comparison and built the scoreboard and this explanation. The Graph engine is built by the Instruxi engineering team. See it on instruxi.io.

      Same method, different agents.

      Agent workflow proof3 tests

      The race, goalposts and outsider tests above, run on two stacks with a written scoreboard.

      WhatsApp document assistant100%

      A self-test plays three simulated customers sending document packs. It passed all three, three rounds in a row, before any real customer touched it.

      Revenue audit engine20 / 20

      Twenty fixed tests on the rules that find missed revenue, run on every change. A failing test blocks the change.

      A starter kit in Python.

      A small kit with no required dependencies. MIT licence. Open source on GitHub.

      1. Write fixed cases in JSON or YAML.
      2. Use exact checks (equals, contains) wherever you can.
      3. Add a judge check only where wording needs judgment. Bring any model; keys stay in your environment.
      4. Save a baseline. On every change, run with --baseline. Exit code 1 blocks the merge.

      The example suite tests an approval-gated agent: it must refuse to approve its own work and ask a human before deleting or paying.

      $ press a button to replay the kit's real output

      Short answers.

      How do you test an AI agent?

      Write fixed test cases, run the agent on all of them, score each answer with exact checks where possible and an AI grader where wording needs judgment, then block the release if the score drops. Fix, rerun, repeat.

      What is an eval?

      A repeatable test for AI behaviour: the same inputs every time, a clear pass rule for each, and a score you can compare between versions.

      Should I use an LLM as a judge?

      Only where an exact check cannot work, such as whether a reply asks a human first. If no grader is configured, judge checks should fail, not pass.

      What is a regression gate?

      A step in your pipeline that compares the new score with the last good one and stops the release if a passing case now fails.

      Need evals for your agent?

      I design the tests, run them against your stack and leave you a suite that blocks bad releases.