Skip to content

API

The public API is what roguebench/__init__.py exports. Everything listed here is importable as roguebench.<name>. The CLI is a thin layer over these functions.

import roguebench as rb

rb.suites()                                   # the ten environments
rb.scenarios(suite="support_agent")           # replications with their incidents and conditions
out = rb.run(rb.RunConfig(model="gpt-5.6-luna", suites=["support_agent"], reps=1))
print(rb.report(rb.score(out)))

rb.__version__ is the package version. The API may still change before 1.0.

Registry

suites() -> list[Suite]

The ten suites.

suite(sid: str) -> Suite

One suite by id. Raises KeyError with the known ids if there is none.

class Suite

A frozen dataclass.

Field Type Meaning
id str for example support_agent
name str display name
agent str what the simulated environment is
harm str the harm its state check looks for
docker bool whether the suite needs Docker
scenarios list[Scenario] property: the suite's scenarios

scenarios(suite=None, track=None, variants=True) -> list[Scenario]

All scenarios, optionally of one suite and one track ("frozen" or "live"). variants=False leaves out the two adaptive variants and returns the 108 replications of the frozen track.

scenario(key: str) -> Scenario

One scenario by key, "<suite>/<id>". Raises KeyError if unknown.

class Scenario

A frozen dataclass.

Field Type Meaning
key str <suite>/<id>
suite, id str the two parts of the key
title str what the agent faced
incidents tuple[str, ...] ids of the incident records it rebuilds
setting, root_cause str or None classification of the incident
variant_of str or None set for the adaptive variants
conditions tuple[str, ...] which of trigger, control, defense, adaptive, adaptive+defense it has
version str 1.0 or live-YYYY-MM-DD
track str frozen or live
added, status, module str or None live scenarios only
reference_verdict str or None verdict over the paper's five models
sources list[str] property: the source URLs of its incidents

incidents() -> dict

Incident id to record. A record has title, date, product, vendor, what, harm_text, mechanism, evidence, setting, root_cause, harm, adversary and sources.

reference() -> dict

{"models": [{"id", "name"}, ...], "counts": {scenario key: {model id: {condition: [harmful, finished, errored]}}}}: the paper's five models.

versions() -> list[str]

["1.0", "live-YYYY-MM-DD", ...].

Running

class RunConfig

A dataclass; only model is required.

Field Default Meaning
model model name, compat/<id>, mock, or py:FILE.py:FUNCTION for your own agent
name None display name and file tag
suites None list of suite ids; None is all
scenarios None list of "<suite>/<id>" or "<suite>"
track "core" core or full
live "none" none, only or also
reps 3 repetitions
out Path("runs") output folder
parallel 4 suites run at once
docker True False skips the two Docker suites
defense None benchmark-wide defenses, comma-separated
plugins None plug-in files or modules
attack None attack name
detector_model None model for the detector and tool_filter defenses
tool_mode "text" text (the suites' protocol) or native (the provider's function calling)
incidents_after None "YYYY-MM-DD": only scenarios whose incidents were first reported after that date
env None extra environment variables for the suites' processes
dry_run False print the settings, run nothing

cfg.tag is the file tag: the name or model, then +defense, @attack and +native if set.

plan(cfg: RunConfig) -> dict

Sessions per suite (and live/<suite>), estimated from the reference runs times cfg.reps.

run(cfg: RunConfig, log=print) -> pathlib.Path

Runs the sessions and returns the output folder. It writes run_<tag>.json and the session files described in Get started. It does not score; call score next. A run that stops resumes when called again with the same settings.

Scoring

score(out, tag=None) -> dict

Scores the sessions of a run folder. Returns {tag: {"frozen": ..., "live": ..., "reference": ...}}. frozen and live are None if the folder has no sessions of that track.

The frozen and live dictionaries have these keys:

Key Content
tag, scenarios the tag, and the number of scenarios with incident sessions
harm_incident, harm_control {"harmful", "sessions", "rate", "ci95"}
lift incident rate minus control rate
p_stratified one-sided exact test, stratified by scenario
verdicts, reproduced count per verdict, and supported plus suggestive
utility_benign, utility_incident {"completed", "sessions", "rate", "ci95"}
harm_defense, harm_adaptive, harm_adaptive_defense same shape as harm_incident; present when sessions exist
errors errored sessions
per_scenario scenario key to {"verdict", "q", <condition>: [harmful, finished, errored]}

reference is {"new_failures": [...], "resists": [...]}, see Scoring.

report(scores: dict) -> str

Markdown report of what score returned.

reference_scores() -> dict

score_tag results of the paper's five models, computed from the shipped counts. Same keys as above, keyed by model id.

Gym-style environment

make(scenario=None, condition="incident", tool_mode="text", reward=None, ...) -> RogueEnv

One scenario as an environment (scenario is SUITE/ID; without it each reset draws one from the train split): obs, info = env.reset(seed=...), then obs, reward, terminated, truncated, info = env.step(reply) until the session ends; info carries harm, completed and the session row. A gymnasium.Env when gymnasium is installed (pip install 'rogue-ai-bench[gym]'). Details: Gym-style environment.

scenarios_for(split="train", suite=None, docker=None) -> list[Scenario]

The fixed train/test split of the frozen replications ("train", "test" or "all"). Training on test scenarios voids benchmark claims.

Other modules

These are not in __all__ but are stable enough to use.

Name Use
roguebench.registry.CONDITIONS the five condition names
roguebench.registry.select(suites, keys, track, incidents_after=None) suite to scenario ids for a selection
roguebench.registry.news() incidents reported after the paper that passed the source check, newest first
roguebench.registry.first_reported(scenario) the earliest report date of a scenario's incidents
roguebench.scoring.score_tag(cells, tag) the numbers of one model from {scenario: {condition: [harmful, finished, errored, ...]}}
roguebench.scoring.tally(out) the counts of a run folder
roguebench.scoring.wilson(k, n) Wilson 95% interval
roguebench.attacks.ATTACKS, register_attack(name), vectors(), apply(work, attack, sims) the attack templates and injection vectors
roguebench.leaderboard.entry_from_run, validate, recompute, entries, table, reference_entries leaderboard entries
roguebench.check.check(suites, live, docker) the offline checks; returns True if all pass
roguebench.registry.subset(name), subsets(), canary() the lite subset's scenario keys, the subset names, the canary string
roguebench.frameworks.wanted(ids), rollup(scenarios) OWASP ids and per-tag counts (Security frameworks)
roguebench.scoring.reliability(cells, keys) harm@k, safe^k and utility^k from per-scenario counts
roguebench.gate.evaluate(frozen_scores, max_harm=..., baseline=...) the CI gate's decision (Use it in CI)
roguebench.reports.build_html(run_dir), build_junit(run_dir) the shareable report and JUnit XML
roguebench.otel.build(run_dir), send(requests, endpoint, headers) OpenTelemetry traces (Export traces)
roguebench.monitor.run(sessions, monitor, out) the monitor track (Monitor track)
roguebench.harbor Harbor task export and import (Agent products through Harbor)
roguebench.inspect_eval.roguebench the Inspect task (Run with Inspect AI)
roguebench.cli.build_parser() the whole command line, as an argparse parser (Command reference)

Example: score two repetitions of your own agent

import pathlib
import roguebench as rb

cfg = rb.RunConfig(model="py:my_agent.py:act", name="my-agent", suites=["support_agent"],
                   reps=2, out=pathlib.Path("runs"))
out = rb.run(cfg)
scores = rb.score(out, cfg.tag)
f = scores[cfg.tag]["frozen"]
print(f["harm_incident"]["rate"], f["harm_control"]["rate"], f["verdicts"])