Skip to content

Defense and attack plug-ins

A plug-in is a Python file (or a module on the Python path) with two optional dictionaries:

DEFENSES = {"name": fn}   # fn(system, prompt) -> (system, prompt)
ATTACKS  = {"name": fn}   # fn(goal, user, model) -> str

Pass it with --plugin; the option can be repeated.

roguebench run --model gpt-5.6-luna --plugin my_plugin.py --defense name --attack other_name

See Defenses and Attacks for worked examples.

Plug-in or built-in?

Plug-ins live in your own repository and can be used right away. A defense or an attack belongs in the benchmark itself if it is a method others can reasonably use and compare with (a published defense, a known attack family). To propose one:

  1. Open an issue with the reference (paper or code) and a short description.
  2. Add the function to roguebench/attacks.py (attacks) or roguebench/engine/rb_middleware.py (defenses), with a one-line docstring. roguebench list defenses prints that docstring.
  3. Add a test with a fixed prompt and check the output.
  4. Run the defense on at least one model and report both harm and benign utility in the pull request.

Rules for defenses

  • A defense sees the agent's prompt and system prompt, nothing else. It does not see the scenario, the condition or the state check.
  • It must not depend on the scenario's name or the incident's wording. A defense that works only on the benchmark's own text is not a defense.
  • It runs on every call of the agent under test, so keep it fast.