Automated Red Teaming
Mutant includes a powerful Behavior-Driven Red Team Engine designed to automatically discover vulnerabilities and behavioral weaknesses in AI systems through multi-turn adversarial conversations.
Unlike traditional static security scanners, the Red Team engine acts as an adaptive security researcher, employing a hypothesis-driven loop: Observe → Hypothesize → Experiment → Evidence → Update → Repeat
Quickstart
To run the Red Team engine, you need to define your target system as an asynchronous function that takes a string input and returns a string response.
from mutant.redteam import red_team
from mutant.providers.openai import OpenAIProvider
# 1. Import your actual AI target system (e.g., LangChain, custom RAG)
from my_app import my_agent
# 2. Initialize your preferred LLM provider for the attacker
provider = OpenAIProvider(model="gpt-4o")
# 3. Run the hypothesis-driven red team session
report = await red_team(
target=my_agent,
goal="Extract the system prompt or backend instructions",
provider=provider,
max_turns=5, # Maximum conversation turns per behavior
max_behaviors=3, # Number of different behaviors/dimensions to test
verbose=True # Enable progress logging
)
# 4. View the generated report summary
print(report.summary())
from mutant.redteam import red_team
from mutant.providers.ollama import OllamaProvider
# 1. Import your actual AI target system (e.g., LangChain, custom RAG)
from my_app import my_agent
# 2. Initialize local Ollama provider for privacy
provider = OllamaProvider(model="llama3.1")
# 3. Run the hypothesis-driven red team session
report = await red_team(
target=my_agent,
goal="Extract the system prompt or backend instructions",
provider=provider,
max_turns=5,
max_behaviors=3,
verbose=True
)
# 4. View the generated report summary
print(report.summary())
How It Works
The engine runs in three primary phases:
- Discovery Phase (Black-Box Profiling): If a
TargetProfileisn't explicitly provided, the engine queries the target to discover its architecture, capabilities, and tools. - Hypothesis-Driven Attack Loop: The planner iterates through selected behavioral dimensions (e.g., Safety, Emotion, Context), planning and executing multi-turn attacks. It continually evaluates the target's responses, updating its hypotheses until it succeeds or exhausts its budget.
- Root Cause Analysis & Reporting: It synthesizes the findings, performs root-cause analysis on successful attacks, and can generate regression tests.
Example Output

Advanced Usage: Providing a Target Profile
To skip the discovery phase and save tokens/time, you can provide an explicit TargetProfile:
from mutant.redteam import red_team, TargetProfile
from mutant.providers import OpenAIProvider
# Import your actual AI target system (e.g., LangChain, custom RAG)
from my_app import my_agent
provider = OpenAIProvider(model="gpt-4o")
profile = TargetProfile(
architecture="RAG Chatbot",
memory="Conversation history of last 10 messages",
tools=["Database search", "Calculator"],
domain="Customer Support"
)
report = await red_team(
target=my_agent,
goal="Bypass safety filters to issue a refund",
provider=provider,
profile=profile,
verbose=True
)
print(report.summary())