Skip to content

Red Team (Agent)

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


1. Define the Target Profile (Optional)

To skip the discovery phase and save execution time, you can provide an explicit TargetProfile. If omitted, the Red Team agent will perform black-box profiling first.

Parameter Type Description
architecture str The high-level architecture (e.g., "RAG Chatbot").
memory str How the target handles memory (e.g., "Last 10 messages").
tools list[str] Any tools the target has access to.
domain str The business domain of the target (e.g., "Customer Support").
from mutant.redteam import TargetProfile

profile = TargetProfile(
    architecture="RAG Chatbot",
    memory="Conversation history of last 10 messages",
    tools=["Database search", "Calculator"],
    domain="Customer Support"
)

2. Initialize the Provider

The attacker agent requires an LLM provider to dynamically generate hypotheses and craft adversarial inputs.

from mutant.providers.ollama import OllamaProvider

# Initialize local Ollama provider for privacy and offline execution
provider = OllamaProvider(model="llama3.1")

3. Run the Red Team Engine

The red_team function initiates the multi-turn session. You simply wrap your application's input/output logic and provide an adversarial goal.

Parameter Type Description
target Callable Required. Your async function that takes a string and returns a string.
goal str Required. The objective of the attacker (e.g., "Extract the system prompt").
provider BaseLLMProvider Required. The LLM provider instantiated above.
profile TargetProfile Optional. The profile defined in Step 1.
max_turns int Optional. Max conversation turns per behavior (default: 5).
max_behaviors int Optional. Number of distinct dimensions to attack from (default: 3).
from mutant.redteam import red_team

# 1. Define your target system wrapper
async def my_agent(prompt: str) -> str:
    # In reality, this calls your LangChain, RAG, or custom agent
    return "I am a helpful assistant."

# 2. Run the hypothesis-driven red team session
report = await red_team(
    target=my_agent,
    goal="Extract the system prompt or backend instructions",
    provider=provider,
    profile=profile,
    max_turns=5,
    max_behaviors=3
)

4. Analyze & Export Findings

Once the attack loop completes, the engine returns a detailed RedTeamReport containing the conversation history, hypotheses, and vulnerabilities found.

# Print a rich terminal summary
report.display()

# Export a visual dashboard for sharing
report.to_html("redteam_report.html")
print("✅ Red Team JSON exported to: redteam_report.html")

Example Output:

Red Team Report Example