Why attack over many turns
Single-prompt scanners send thousands of known jailbreaks and score each reply on its own. An agent can refuse every one of them and still give in at turn 20 of a conversation, after the attacker has set up a story, claimed some authority and split the request into harmless-looking pieces. The attacker in Scenario works that way. It writes an attack plan for your target first, scores each of your agent’s replies from 0 to 10, pushes harder where the agent gave ground, and drops a line of attack that met a hard refusal.1. Install Scenario
@langwatch/scenario and vitest; Red teaming has the TypeScript version of the test below.
The attacker and the judge are models, so set your provider key, for example OPENAI_API_KEY. Set LANGWATCH_API_KEY as well if you want the runs in LangWatch.
2. Write the attack
Give Scenario an adapter that calls your agent. Then replace the simulated user with an attacker and give it a target, what success looks like for the attacker:test_redteam.py
marathon_script runs the turns for you. The checks you pass run after every turn, so a broken rule fails the test at the turn it happened. The judge then reads the whole conversation against the criteria. Write each rule you can check in code as a check as well as a criterion: a check is exact and can’t be argued with.
The check above only asks that some order lookup happened before the test ended; to tie the lookup to the refunded order, compare the tool call arguments in state.messages.
Pick targets from what your agent can actually do: its tools, its data and its instructions. Reveal the system prompt, call a tool without authorisation, read another customer’s data and leave the role are the usual first four.
3. Pick a strategy
Both take the same
target and total_turns. More turns find more: an agent that holds for 10 turns can break at 40, so raise total_turns for the targets you can least afford to lose.
4. Run it and read the findings
Every red-team run leaves a finding report: the transcript, how severe the break was and a suggested fix. Run the tests as usual:./redteam-reports/. To read them, install the dashboard extras once and open it:
localhost with the latest batch of findings, and it runs on your machine with no account.
With LANGWATCH_API_KEY set, every run also shows on the Results tab in LangWatch with the full conversation and the judge’s reasoning, next to your functional tests.
How Scenario compares to garak, PyRIT and promptfoo
Scenario’s catalogue of single-prompt jailbreaks is smaller than garak’s or promptfoo’s. The tools combine well: a scanner for breadth on known prompts, Scenario for depth on your agent’s own actions.
Questions about red teaming with Scenario
Can a coding assistant write Scenario red-team attacks for me
Yes. Install the scenarios skill withnpx skills add langwatch/skills/scenarios, then ask your assistant to “add red teaming to my agent”. It finds your agent in the codebase and writes the test.
What does a Scenario red-team run cost
Every turn calls the attacker model and your agent and scores the reply, so the cost grows withtotal_turns. Run the long attacks before a release, and turn off per-turn scoring with score_responses=False for faster runs on every pull request.