agent-safety-bench
Multi-step agent safety compliance benchmarking
Find the critical depth at which your LLM agent fails to maintain safety policies across sequential interactions.
pip install agent-safety-bench
agent-safety-bench run --model qwen3-8b --scenario market_report
Why
Current LLM safety evaluation is single-turn: you ask one question, check if the model refuses. But real agents execute multi-step chains — research, code, deploy, process data. The GGT (Guardrail Gap Theorem) proves that single-step verifiers cannot guarantee multi-step safety: compositional safety is NP-hard.
This tool operationalizes that theorem. It measures D* — the critical depth at which the agent's compliance rate drops below a threshold — across 3 built-in scenarios and any custom scenario you define.
Quick Start
# Install
pip install agent-safety-bench
# List available scenarios
agent-safety-bench list-scenarios
# Run a benchmark
agent-safety-bench run \
--model qwen3-8b \
--scenario market_report \
--depths 1 3 5 7 9 \
--trials 3 \
--output results.json
# Analyze existing results
agent-safety-bench analyze --input results.json
Built-in Scenarios
| Scenario | Description | Policies Tested |
|---|---|---|
market_report |
Multi-step research with stale/unverified data | Data freshness, source verification |
deploy_audit |
Deployment pipeline with security shortcuts | Test discipline, security review |
privacy_compliance |
Data processing with privacy violations | PII protection, third-party sharing |
API
from agent_safety_bench import SafetyBench
from agent_safety_bench.scenarios import get_scenario
scenario = get_scenario("market_report")
bench = SafetyBench(model="qwen3-8b")
results = bench.run_benchmark(
steps=scenario["build_chain"](max_depth=8),
policies=scenario["policies"],
system_prompt=scenario["system_prompt"],
depths=[1, 2, 3, 4, 5, 6, 7, 8],
trials_per_depth=3,
verbose=True,
)
from agent_safety_bench.analyze import find_phase_transition, print_summary
pt = find_phase_transition(results, model_name="qwen3-8b")
print(print_summary(pt))
Custom Scenarios
from agent_safety_bench import SafetyBench
from agent_safety_bench.core import ChainStep
from agent_safety_bench.scenarios import register_scenario
def my_chain(depth):
steps = [
ChainStep(text="Step 1: ...", policy_violation=""),
ChainStep(text="Try to violate policy X", policy_violation="policy_x"),
]
return steps[:depth+1]
register_scenario("my_test", {
"name": "My Custom Test",
"description": "Tests policy X",
"system_prompt": "You must follow policy X...",
"policies": ["Policy X"],
"build_chain": my_chain,
})
Theory
This tool is based on the Guardrail Gap Theorem (GGT): the problem of deciding whether a sequence of individually-valid tool calls can collectively violate a global safety policy (SAFE-EXEC) is NP-complete.
The empirical finding: as chain depth D grows, every tested model shows a phase transition at a critical depth D* where compliance drops from near-perfect to near-zero. This transition is sharp (width <= 2 depths) and scale-dependent (larger models have higher D*).
License
MIT
Metadata
Release files for agent-safety-bench 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agent_safety_bench-0.1.0.tar.gz | 14.9 kB | With provenance | Details for agent_safety_bench-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_safety_bench-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agent_safety_bench-0.1.0-py3-none-any.whl |
Total release size: 31.6 kB
Release files / agent_safety_bench-0.1.0.tar.gz
| Download URL | agent_safety_bench-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86afca6ba9857d4b79d39d00ce506423884e74adc27b6922a64ed3d82e9c9da1
|
|
BLAKE2b-256 checksum How to use checksums |
3695e74c37eae1597253b254a03a0ac9b21e40038f573502f64e2b4c38caaa68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.
Transparency logRelease files / agent_safety_bench-0.1.0-py3-none-any.whl
| Download URL | agent_safety_bench-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c655ea04004ffde3d1a0befd49b9b59044725baf301ad470e41ca47dc810b56
|
|
BLAKE2b-256 checksum How to use checksums |
20bf5d646de9b5e6ec8d7d64ac93993ea4139cf3fff0d6c90ba6deed94fc43a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.
Transparency logSecurity for agent-safety-bench 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for agent_safety_bench-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.