Run the benchmarks

The benchmark/ folder runs the paper’s experiments on four public agent benchmarks, using this library. For each benchmark it has the code to load the tasks, the benchmark’s policy, the hook that puts the guard in front of the agent’s tool calls, a runner, and a check against the paper’s recorded runs.

folder benchmark domains
benchmark/tau2/ τ²-bench airline, retail, telecom, and a test with ambiguous timeouts
benchmark/dtap/ DecodingTrust-Agent (DTap) telecom, travel, finance, legal, customer service
benchmark/agentdojo/ AgentDojo and AgentDyn the AgentDojo suites; AgentDyn shopping, github, dailylife
benchmark/common/ shared code paths, guard settings, model endpoints, episode records, the LLM-judge baseline

This page gives the main commands. The benchmark README has every detail.

Setup

pip install -e ".[bench]"          # the library and the shared tools
python -m benchmark.fetch          # download the benchmarks, at the versions the paper used, into vendor/
pip install -e vendor/tau2-bench   # τ²-bench (it needs Python 3.12 or 3.13)
pip install -e vendor/agentdojo    # AgentDojo

AgentDyn uses the same package name as AgentDojo, so install it in a separate environment: pip install -e vendor/AgentDyn.

Two settings change where things go:

  • CAUSALREPAIR_BENCH: the folder that holds the benchmarks (default vendor/);
  • CAUSALREPAIR_RUNS: the folder where runs are written (default runs/).

Every model runs behind an OpenAI-compatible server. The paper used vLLM with five Qwen agents (Qwen3.5 0.8B, 2B, 4B, 9B and Qwen3.8-27B), with thinking off. For example:

vllm serve Qwen/Qwen3.5-9B --port 20001 --tool-call-parser qwen3_coder --reasoning-parser qwen3 \
    --enable-auto-tool-choice --language-model-only --enable-prefix-caching

The three steps

Every benchmark follows the same three steps. Fix them before you run any test episode.

  1. Collect. Run the agent on the collection tasks with the guard in collect mode.
  2. Fit. python -m benchmark.fit fits a learned guard on those logs and saves it. One file holds both learned rules.
  3. Test. Run every guard setting on the held-out test tasks, then compare them with python -m benchmark.summarize.

The guard settings (“arms”):

arm what the guard does
off no guard (the policy is still checked and logged)
block deny every call that breaks a rule
feedback tell the agent which rules the call broke
nearest the nearest repair
collect random picks with exact chances, to make logs for the fit
learned the learned guard, risk-limited rule
matched the learned guard, matched-harm rule
judge a baseline: a language model reads the rules, the conversation and the call, and allows or denies it

Where results go

Each episode is one JSON file under runs/<benchmark>/<phase>/<model>/<arm>/. It is written as soon as the episode ends, so a stopped run starts again where it stopped. Each file holds every guard decision and the outcome: harm, success and safe_completion. Episodes marked unscored (a model, simulator or judge failure) are kept, but they are never fitted or counted.

python -m benchmark.summarize runs/tau2/test/Qwen3.5-9B               # one row per arm, with 95% intervals
python -m benchmark.summarize runs/tau2/test/*/nearest --by domain    # one row per domain

τ²-bench

A="--model Qwen/Qwen3.5-9B --agent-url http://127.0.0.1:20001/v1 --user-url http://127.0.0.1:20002/v1"
python -m benchmark.tau2.run --phase collect --arm collect $A
python -m benchmark.fit runs/tau2/collect/Qwen3.5-9B/collect --pooled runs/tau2/collect \
    --per-domain --boot 200 --out artifacts/tau2/Qwen3.5-9B.json
for arm in off block feedback nearest; do python -m benchmark.tau2.run --phase test --arm $arm $A; done
python -m benchmark.tau2.run --phase test --arm learned --artifact artifacts/tau2/Qwen3.5-9B.json $A
python -m benchmark.tau2.run --phase test --arm matched --artifact artifacts/tau2/Qwen3.5-9B.json $A
python -m benchmark.tau2.run --phase test --arm judge --judge-url http://127.0.0.1:20002/v1 $A
python -m benchmark.summarize runs/tau2/test/Qwen3.5-9B

--user-url is the server of the simulated user (the paper used Qwen3.8-27B). To try a few tasks first, add --limit 2 or --task-ids ....

The timeout test. --timeouts makes the first try of each write that is unsafe to repeat time out with an unknown result (airline book_reservation and send_certificate; telecom refuel_data and send_payment_request). With chance 0.5 the write still reached the backend. A repeat that the backend also accepts is then a duplicate write, which counts as harm. Two hand-written guards are included for comparison: verify_after_timeout and check_then_act.

T="--timeouts --domains airline,telecom --once confirm_first,verify_first"
python -m benchmark.tau2.run --phase collect_timeouts --arm collect $T $A
python -m benchmark.fit runs/tau2/collect_timeouts/Qwen3.5-9B/collect --pooled runs/tau2/collect_timeouts \
    --per-domain --out artifacts/tau2_timeouts/Qwen3.5-9B.json
for arm in nearest verify_after_timeout check_then_act; do
  python -m benchmark.tau2.run --phase test_timeouts --arm $arm $T $A; done
python -m benchmark.tau2.run --phase test_timeouts --arm learned $T --artifact artifacts/tau2_timeouts/Qwen3.5-9B.json $A

DecodingTrust-Agent (DTap)

DTap needs its simulators. Start them with DTap’s own Docker compose files, then run:

python -m benchmark.fetch dtap
pip install "fastmcp>=2,<3" ujson beautifulsoup4 psycopg2-binary pyyaml pandas

D=telecom    # or travel, finance, legal, customer_service
A="--model Qwen/Qwen3.5-9B --agent-url http://127.0.0.1:20001/v1"
python -m benchmark.dtap.run --domain $D --phase collect --arm collect $A
python -m benchmark.fit runs/dtap/collect/Qwen3.5-9B/collect/$D --pooled runs/dtap/collect/*/collect/$D \
    --boot 200 --out artifacts/dtap/$D/Qwen3.5-9B.json
for arm in off block feedback nearest; do python -m benchmark.dtap.run --domain $D --phase test --arm $arm $A; done
for arm in learned matched; do
  python -m benchmark.dtap.run --domain $D --phase test --arm $arm --artifact artifacts/dtap/$D/Qwen3.5-9B.json $A; done
python -m benchmark.summarize runs/dtap/test/Qwen3.5-9B/*/$D

The benchmark README lists the compose commands and the ports of each simulator.

AgentDojo and AgentDyn

A="--model Qwen/Qwen3.5-9B --agent-url http://127.0.0.1:20001/v1"
python -m benchmark.agentdojo.run --benchmark agentdojo --phase collect --arm collect $A
python -m benchmark.fit runs/agentdojo/collect/Qwen3.5-9B/collect --pooled runs/agentdojo/collect \
    --boot 200 --out artifacts/agentdojo/Qwen3.5-9B.json
for arm in off block feedback nearest; do
  python -m benchmark.agentdojo.run --benchmark agentdojo --phase test --arm $arm $A; done
for arm in learned matched; do
  python -m benchmark.agentdojo.run --benchmark agentdojo --phase test --arm $arm \
      --artifact artifacts/agentdojo/Qwen3.5-9B.json $A; done
python -m benchmark.summarize runs/agentdojo/test/Qwen3.5-9B

For AgentDyn, use --benchmark agentdyn in its own environment. To check the setup without a model server, add --scripted --suites banking --limit 20: a scripted agent makes the reference calls.

Check against the paper’s runs

Each benchmark has a replay. It walks the paper’s recorded episodes through the guard of this library and compares every decision: the broken rules, the menu, the situation label and the chosen option. On every recorded run of the paper, the decisions are the same. Two exceptions: the judge’s choice is not compared, because a language model makes it; and for some DTap rules that need live simulator state, the replay uses the recorded verdict and checks everything after it.

python -m benchmark.tau2.replay results/tau2/collect results/tau2/test
python -m benchmark.dtap.replay
python -m benchmark.agentdojo.replay

The replays need the paper’s recorded runs (a results/ folder). They are not part of this repository.

Help for each command

Every command explains its options:

python -m benchmark.tau2.run --help
python -m benchmark.fit --help