Red teaming AI systems
Attack your own AI system, with expert humans and automated tools, before launch and on every change; rate findings by severity and turn each one into a regression eval.
Analogy: Hiring a burglar to break into your house before a real one does, then fixing every window they used and re-testing them after each renovation.
How it works
- Evals ask whether it works on expected inputs; red teaming asks the worst it can be made to do.
- Scope comes from this system's threat model: harmful content, injection, data leakage, agent misuse and bias.
- Automated tools like PyRIT, garak and promptfoo generate and mutate thousands of attacks and score the responses.
- Human experts still find the novel, multi-turn and business-logic attacks that tools miss.
- Report attack success rate per category per release; any open critical finding blocks launch.
Check yourself
Answer to mark it learned; your answers aren't scored.
Your red-team pass typed 2,000 single-turn English attacks straight into the chat box; attack success rate was under 1%. The agent reads inbound customer emails and can issue refunds. Before sign-off, which addition finds the most?
Go deeper
Full explanation
Red teaming is attacking your own AI system the way a motivated adversary or a careless user would, before launch and continuously after, to find the failures normal evals miss. Evals ask "does it work on expected inputs?"; red teaming asks "what's the worst it can be made to do?"
Scope comes from a threat model of this system, not a generic list:
- Harmful content: jailbreaks into dangerous, hateful or illegal output.
- Prompt injection: direct, and indirect via documents, emails, web pages and tool results.
- Data leakage: system prompt, PII, secrets, other users' or tenants' data.
- Agent misuse: unauthorized tool calls, excessive agency, spending money, deleting things.
- Bias: different quality or treatment across groups and languages.
Two kinds of attacker, both needed:
- Expert manual testing: security and domain experts find novel, multi-turn and business-logic attacks.
- Automated generation: Microsoft PyRIT, NVIDIA garak and promptfoo's red-team mode generate and mutate thousands of attacks (encodings, role-play, multi-turn escalation) and score the responses.
Rate each finding by severity (impact × likelihood), fix critical ones before launch, and turn every finding into a regression eval that runs in CI on each model, prompt or tool change. After launch, a bug bounty and user reports keep feeding the set.
Code promptfoo red-team config against a staging agent
# promptfooconfig.yaml -> npx promptfoo@latest redteam run
description: Red team for the support agent (staging)
targets:
- id: https
label: support-agent-staging
config:
url: https://staging.example.com/api/chat
method: POST
headers: { Content-Type: application/json }
body: { message: "{{prompt}}", user_id: "redteam-01" }
transformResponse: json.reply
redteam:
# The purpose drives attack generation: say what it may and may NOT do
purpose: >-
Bank support assistant. May read the caller's own orders and issue
refunds up to $50. Must never reveal other customers' data.
numTests: 25 # attacks generated per plugin
plugins:
- harmful:hate
- pii:direct # tries to extract personal data
- bola # other users' records (broken object-level auth)
- excessive-agency # actions beyond what was asked
- hijacking # off-purpose use of the agent
strategies:
- jailbreak # iterative, LLM-driven refinement
- crescendo # multi-turn escalation
- base64 # encoding obfuscationReal example
Before launching an email agent that can read the inbox and send messages, a team spends two weeks red teaming. promptfoo generates ~3,000 attacks across 10 plugins; garak adds encoding and leakage probes; two security engineers attack it by hand. The worst finding comes from the humans: an incoming email with hidden instructions makes the agent forward the last 10 invoices to an outside address. Rated critical (data exfiltration, reproducible in 7 of 10 runs), it is fixed by requiring confirmation before sending to any new external recipient. The email joins the regression suite; three months later a model upgrade raises its success rate from 0/10 to 2/10 and the CI gate blocks the deploy.
Trade-offs +3 · −3
+ You gain
- Finds the failures that matter most: the ones nobody thought to test.
- Automated suites make attacks repeatable and cheap to re-run on every change.
- Gives launch decisions evidence: severity-ranked findings instead of opinions.
− You pay
- Never proves safety: finding nothing is not the same as having no holes.
- Skilled human red teamers are scarce and expensive; automation mostly finds known patterns.
- LLM-graded attack success is noisy; findings need human triage.
Use it when
Before any public launch, before giving an agent new tools or data, and on every model upgrade; scale it to risk: a day for an internal summarizer, weeks for an agent that moves money.
Avoid it when
As a substitute for secure design or regular evals. Don't red team a prototype whose permissions and data flows will still change: threat-model first, attack once the architecture stabilizes.
Numbers to know 4
- Anthropic released ~39k human red-team attacks (Ganguli et al., 2022), a public seed set for your own suite.
- PAIR, an attacker LLM refining prompts against a target model, often finds a jailbreak in under 20 queries.
- Rule of thumb: report attack success rate (ASR) per category per release; any open critical finding blocks launch.
- Rule of thumb: re-run the automated suite on every model, prompt or tool change; upgrades can reopen fixed holes.
Common pitfalls 4
- Testing only single-turn, English, direct prompts; real attacks are multi-turn, multilingual and indirect.
- Red teaming once before launch; a model or prompt change silently reopens fixed holes.
- Attacking the bare model instead of the full system with its tools, retrieval and guardrails.
- Findings that live in a slide deck instead of becoming regression tests.
Interview questions 2
Answer out loud first, then reveal.
How would you set up red teaming for a new agent launch?Show answer
I start with a threat model of the actual system: what data it reads, what tools it calls, who would attack it. That fixes scope and a severity rubric up front: data exfiltration or an unauthorized action is critical and blocks launch. Then two tracks in parallel: automated generation with promptfoo or PyRIT for breadth, and expert humans for multi-turn and business-logic attacks, which is usually where the worst findings come from. Every finding becomes a regression eval in CI, and after launch a bug bounty keeps the pipeline fed.
The model provider already red-teamed the model. Why do it again?Show answer
Because they tested a model and I ship a system. The provider can't know my tools, my data, my system prompt or my users. Most serious findings live in that integration: an injection in a retrieved document that triggers my refund tool, another tenant's data leaking through retrieval, a guardrail bypassed by writing in Spanish. Model-level safety is a floor; my red team covers what I built on top, and re-runs whenever I swap the model.