Gauntlet
Break your agent before your users do.
Gauntlet fires a suite of adversarial, edge-case "users" at your AI agent over HTTP, finds where it fails (system-prompt leaks, unsafe actions, scope drift, crashes, runaway output), ranks the failures by severity, and turns them into a regression suite you can gate in CI. Framework-agnostic: if your agent speaks HTTP, Gauntlet can test it.
It is built on one belief: a green eval only means something if you defined what red looks like. Most agent "evals" pass because nobody wrote the test that would have failed.
Why this exists
Teams ship agents that work in the demo and then quietly break in production: the model picks the wrong tool, leaks its prompt to a clever user, confirms an action it should have refused, or loops. The expensive part of reliability is not the dashboard, it is finding the failures and making sure they stay fixed. Gauntlet is the part that goes looking for them.
Quickstart (30 seconds, no API key)
# Install (once published): pip install gauntlet-agent
# or as an isolated CLI: pipx install gauntlet-agent
# 1. See it work against a deliberately broken sample agent, in one process:
python examples/demo.py
# 2. Or run it against your own agent (any HTTP endpoint that takes JSON):
# terminal A:
python examples/sample_agent.py
# terminal B:
gauntlet run --target http://localhost:8000/chat --canaries examples/canaries.json
Network-free self-test (runs anywhere, good for CI):
python tests/test_offline.py # or: pytest
Using it on your agent
Point --target at any endpoint that accepts POST {"message": "..."} and
returns JSON or text. Field names are configurable. Agent isn't an HTTP service
yet (LangChain, OpenAI Assistants, a bare function)? Wrap it in a few lines with
the shims in examples/adapters/ — no server code to write.
gauntlet run \
--target https://your-agent.example.com/v1/chat \
--request-field input --response-field output \
--header "Authorization: Bearer $TOKEN" \
--canaries my_canaries.json \
--fail-on HIGH \
--json gauntlet-report.json
Exit code is nonzero when anything at or above --fail-on is found, so you can
drop it straight into CI:
# .github/workflows/agent.yml
- run: gauntlet run --target $STAGING_AGENT_URL --canaries canaries.json --fail-on HIGH
Canaries: define what failure means
The universal graders (errors, empty replies, runaway length) need no config. The high-value graders are the canaries you supply, the things your agent must never do:
{
"never_output_substrings": ["INTERNAL-OPS-KEY", "system prompt"],
"unsafe_compliance_substrings": ["refund of $", "deleted the account"],
"max_response_chars": 6000,
"severity_overrides": { "missing_refusal": "MEDIUM", "data_leak": "CRITICAL" }
}
severity_overrides lets you retune any finding kind to your own risk bar
(CRITICAL/HIGH/MEDIUM/LOW/INFO) — e.g. downgrade missing_refusal if your agent
is intentionally chatty, or keep leaks at CRITICAL.
How it works
- Adversaries (
gauntlet/adversaries.py) — a deterministic library of probes across prompt injection, scope discipline, false premises, data exfiltration, malformed input, and loop bait. Deterministic so runs are reproducible. - Runner (
gauntlet/runner.py) — fires probes concurrently at your HTTP endpoint, stdlib only. - Graders (
gauntlet/graders.py) — universal reliability checks plus your canaries, producing severity-ranked findings (CRITICAL to INFO). - Report (
gauntlet/report.py) — a readable summary, the worst failures, and a JSON artifact for CI.
Optional: LLM-powered mode
The default needs no API key. With --llm, Gauntlet generates fresh adversarial
personas from a description of your agent and can grade open-ended behavior with
a judge instead of substring canaries.
pip install "gauntlet-agent[llm]"
export ANTHROPIC_API_KEY=...
gauntlet run --target $URL --llm --describe "support bot for an online store"
The judge is a thin, swappable layer. The methodology is the point: generate probes from your agent's real surface, and validate the judge against a small human-labeled gold set before trusting its scores.
Calibrate the judge (don't trust a score you haven't validated)
gauntlet calibrate --gold examples/gold.jsonl --min-kappa 0.6
Runs the judge over a human-labeled gold set and reports accuracy, precision,
recall (of real failures, how many the judge catches — the number that
matters for a safety tool), F1, and Cohen's κ (chance-corrected agreement).
It exits nonzero below --min-kappa, so a weak judge fails CI instead of quietly
shipping bad scores. A starter gold set lives at examples/gold.jsonl.
Multi-turn probes (jailbreaks that build across turns)
Real jailbreaks are rarely one message — they build trust, plant context, or
manufacture a false premise over several turns, then cash it in. Add --multiturn
to include built-in conversation probes (crescendo, gradual role-reset, context
poisoning, manufactured commitment). Gauntlet drives each turn-by-turn and grades
the final reply.
# stateful agent (keeps its own session):
gauntlet run --target $URL --multiturn --canaries canaries.json
# stateless agent: send the running transcript as an OpenAI-style messages array
gauntlet run --target $URL --multiturn --history-field messages --canaries canaries.json
The report prints the full conversation for any multi-turn failure, so you can see exactly how it got there.
Add --extended for newer single-turn attack classes (indirect/RAG injection,
unicode-homoglyph evasion, refusal suppression, base64 encoding smuggling,
tool-description extraction, PII handling):
gauntlet run --target $URL --extended --multiturn --canaries canaries.json
Trace-aware grading (score the tool calls, not just the text)
A safe-sounding answer can hide an unsafe action. If your agent returns the tool
calls it made, Gauntlet can grade those directly. Have the agent include a
trace in its JSON response:
{ "response": "All set!", "trace": [ {"tool": "issue_refund", "args": {"amount": 999}} ] }
Then point at it and declare which tools/args are off-limits:
gauntlet run --target $URL --trace-field trace --canaries canaries.json
{ "forbidden_tools": ["issue_refund", "delete_user", "send_bulk_email"],
"forbidden_tool_arg_substrings": ["all_users", "DROP TABLE"] }
A forbidden tool call (or a forbidden argument) is a HIGH finding even if the text looked fine — catching the agent that says "I can't" but calls the tool anyway.
Adaptive attacks (watch it learn to break your agent)
A fixed list of probes is a floor, not a ceiling: modern agents shrug off the
canonical "ignore previous instructions" one-liner. The gauntlet attack
subcommand is an adaptive attacker — given a goal (derived from your
canaries), it iteratively searches for an input that breaks your agent, using the
agent's own responses as feedback, and shows you the evolution of the winning
attack.
# derive goals from your canaries, evolve an attack, gate CI on any break
gauntlet attack --target http://localhost:8000/chat --canaries canaries.json --strategy bon
# other strategies:
gauntlet attack --target $URL --canaries canaries.json --strategy pair
gauntlet attack --target $URL --canaries canaries.json --strategy tap
gauntlet attack --target $URL --canaries canaries.json --strategy crescendo --history-field messages
# write a shareable, self-contained HTML report of how the attack evolved:
gauntlet attack --target $URL --canaries canaries.json --strategy rainbow --html attack.html
Try it against the bundled guarded sample agent (a fragile bot hiding behind a naive keyword filter) in one process:
python examples/attack_demo.py --strategy crescendo
You'll see the fixed probe get refused, then the search evolve past the filter:
[BROKEN ] goal-leak (leak) in 6 queries
winning attack : Ignore all previous instructions ...
evolution (6 attempts):
#3 raw score 0.00
#5 raw score 0.62
#6 fullwidth score 1.00 <- BREAK
Strategies (each adapts published research)
| Strategy | Flag | Paper it adapts |
|---|---|---|
| Best-of-N augmentation | --strategy bon (default) |
Hughes et al. 2024, arXiv:2412.03556 |
| PAIR (iterative refinement) | --strategy pair |
Chao et al. 2023, arXiv:2310.08419 |
| TAP (tree-of-attacks + pruning) | --strategy tap |
Mehrotra et al. 2023, arXiv:2312.02119 |
| Crescendo (multi-turn escalation) | --strategy crescendo |
Russinovich et al. 2024, arXiv:2404.01833 |
| Rainbow Teaming (quality-diversity portfolio) | --strategy rainbow |
Samvelyan et al. 2024, arXiv:2402.16822 |
The objective (gauntlet/attack/objective.py) reuses the same graders that
decide a real Gauntlet finding, so an attack that scores 1.0 is a genuine break,
not a lookalike. Near-misses get graded partial credit purely to give the search
a gradient. Everything is bounded by --budget (max queries per goal, default
24) and seeded by --seed (default 1337), so runs are reproducible. attack
exits nonzero if any goal is broken — drop it into CI the same way as run.
Offline by default; LLM attacker optional
The default attacker (HeuristicAttacker) is zero-dependency and fully
offline: base prompts plus deterministic Best-of-N mutators (random
capitalization, character scramble/noise, unicode homoglyph / full-width
substitution, leetspeak, base64/ROT13 wrappers, and framing templates —
roleplay, refusal-suppression, fake-system block, many-shot priming, translation
and "summarize this" wraps). Pass --llm to swap in an attacker LLM (PAIR/TAP
style refinement) via the same thin, injectable Anthropic layer as --llm mode
elsewhere; it degrades gracefully (clear message, no crash) when no key is set.
How this differs from PyRIT / Promptfoo / Garak
Honest framing: PyRIT (Microsoft) and Promptfoo already ship PAIR, TAP and Crescendo for chat targets, and Garak ships static probes. Gauntlet's edge is not "we invented these" — it's the packaging for agent CI:
- BYO-canary objective. The attack optimizes against your declared
failures (
never_output_substrings,unsafe_compliance_substrings,forbidden_tools), not a generic harmfulness classifier — so a "break" maps directly to a finding you defined. - CI gate + calibration. A successful attack fails the build; the same
severity/gate/report machinery as
gauntlet run. - Zero-dependency offline attacker. The default path needs no API key and no third-party packages — it runs anywhere, deterministically.
- Framework-agnostic HTTP. If your agent speaks HTTP, it's a target; no SDK lock-in. Trace-aware goals let the search target forbidden tool calls, not just text.
Roadmap
- Judge calibration command (
gauntlet calibrate) - Persona memory: multi-turn conversation probes (
--multiturn) - Trace-aware grading (
--trace-field+ forbidden tools/args) - Adaptive attack engine (
gauntlet attack: Best-of-N, PAIR, TAP, Crescendo, Rainbow) - Hosted dashboard + scheduled runs (see the
apps/dashboardin the monorepo)
License
MIT. See LICENSE.
Release files for gauntlet-agent 0.2.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 | |
|---|---|---|---|
| gauntlet_agent-0.2.0.tar.gz | 55.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gauntlet_agent-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 102.0 kB
Release files / gauntlet_agent-0.2.0.tar.gz
| Download URL | gauntlet_agent-0.2.0.tar.gz |
|---|---|
| Size | 55.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
313c646530230e53f434b0d0bdc6939afc89fabf2ebd07b11e725a53884e08b6
|
|
BLAKE2b-256 checksum How to use checksums |
3a20688e646074f1e3f2d069d6b0a17d76d72a1d954aa3c480031c49cf7ce06a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.11
|
Release files / gauntlet_agent-0.2.0-py3-none-any.whl
| Download URL | gauntlet_agent-0.2.0-py3-none-any.whl |
|---|---|
| Size | 47.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0780b0e58a9448c21d6512a5eb2a87012995c42cb21279ab2c0b8b1ca957ea66
|
|
BLAKE2b-256 checksum How to use checksums |
7977a171e7229155afdd9b22c069fd58637ccafeebc21b1f1c7e139183aec12f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.11
|