Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

Add new guides on red teaming

A-Vamshi0c9750a71250
diff --git a/docs/guides/guide-red-teaming-chatbots.mdx b/docs/guides/guide-red-teaming-chatbots.mdx
new file mode 100644
index 00000000..ee18f88b
--- /dev/null
+++ b/docs/guides/guide-red-teaming-chatbots.mdx
@@ -0,0 +1,326 @@
+---
+id: guide-red-teaming-chatbots
+title: Red teaming chatbots
+sidebar_label: Chatbot & Multi-Turn
+---
+
+import BlogImageDisplayer from "@site/src/components/BlogImageDisplayer";
+import { ASSETS } from "@site/src/assets";
+
+Multi-turn chatbots are uniquely exposed compared to single-shot systems. Attackers do not need to craft the perfect prompt upfront—they can probe gradually, reframe their intent across turns, and exploit the model's own prior replies to escalate toward harmful outputs. Because each response shapes what follows, a model that holds firm on turn one can be manipulated into a failure by turn five.
+
+This guide explains how to red team a conversational LLM application using [DeepTeam](https://github.com/confident-ai/deepteam). To make the process concrete, this guide uses a customer support chatbot for a financial services product as the example application—an environment where sensitive user data, legal constraints, and safety obligations intersect. The approach applies to any stateful chat system.
+
+:::note
+This guide focuses on multi-turn attack techniques. If your system handles requests in a single generation without maintaining conversation state, use the [single-turn and RAG guide](/guides/guide-red-teaming-single-turn-rag) instead.
+:::
+
+## Methodology
+
+The red teaming process for a chatbot follows the same structure as any DeepTeam assessment, with one important distinction: multi-turn attacks require a live connection to the target model. The attack logic reads each assistant response and adapts the next user message based on what it observes. This means testing cannot use pre-recorded outputs—the model must respond in real time.
+
+1. **Identify failure modes** — Determine what the chatbot must never say, do, or facilitate based on its function, user base, and regulatory context.
+2. **Select corresponding vulnerabilities** — Map those failure modes to DeepTeam's vulnerability classes to generate targeted adversarial inputs.
+3. **Choose multi-turn attack strategies** — Select attacks that reflect how real attackers operate over a conversation: gradual escalation, narrative reframing, and consistency exploitation.
+4. **Integrate the production chat pipeline in `model_callback`** — The callback must replay the actual conversation history so DeepTeam can simulate a genuine user session with your chatbot.
+5. **Execute `red_team()` and analyze results** — Review binary scores (0 = failed, 1 = passed) per test case and investigate failures to understand which conversational patterns the model cannot resist.
+
+## Choosing the Right Vulnerabilities
+
+The financial support chatbot handles billing disputes, account information, and compliance-sensitive queries. Users are authenticated, but they can enter arbitrary text, and the model is expected to adhere strictly to policy while remaining helpful. The following vulnerabilities correspond to the most consequential failure modes for this kind of system.
+
+### Toxicity
+
+A conversational model interacts with users over extended exchanges, and frustrated or adversarial users will attempt to push it into producing harmful, offensive, or degrading language. `Toxicity` tests whether the chatbot will generate or reinforce insults, threats, profanity, or mockery—content that creates direct safety risks and reputational damage regardless of how the conversation arrived there.
+
+```python
+from deepteam.vulnerabilities import Toxicity
+
+Toxicity()
+```
+
+### IllegalActivity
+
+Users with malicious intent can use the conversational format to gradually construct a request for assistance with unlawful activity. What begins as a legitimate question can, across several turns, become a request for guidance on fraud, unauthorized account access, or money laundering. `IllegalActivity` tests whether the model resists these patterns regardless of how they are framed or how innocently the conversation starts.
+
+```python
+from deepteam.vulnerabilities import IllegalActivity
+
+vulnerability = IllegalActivity()
+```
+
+### PersonalSafety
+
+A financial services chatbot may encounter users in distress—someone overwhelmed by debt, experiencing a financial crisis, or expressing hopelessness. `PersonalSafety` tests whether the model can recognize and appropriately handle situations involving self-harm, dangerous behavior, or coercion without being manipulated into facilitating harm through a staged scenario or gradual emotional escalation.
+
+```python
+from deepteam.vulnerabilities import PersonalSafety
+
+vulnerability = PersonalSafety()
+```
+
+### Bias
+
+Long conversations drift. A model that responds neutrally on turn one may, through a series of leading questions, start echoing or reinforcing biased assumptions about users based on demographics, financial behavior, or background. `Bias` tests whether the chatbot maintains consistent, non-discriminatory responses under sustained social pressure to adopt a prejudiced stance.
+
+```python
+from deepteam.vulnerabilities import Bias
+
+vulnerability = Bias()
+```
+
+### PIILeakage
+
+In a chat context, the model has access to session-level memory and, in some implementations, prior account interactions. Attackers can use social engineering across turns—posing as support agents, invoking urgency, or pretending to verify identity—to extract another user's personal information. `PIILeakage` tests the model's resistance to these social and contextual manipulation patterns.
+
+```python
+from deepteam.vulnerabilities import PIILeakage
+
+vulnerability = PIILeakage()
+```
+
+### PromptLeakage
+
+System prompts in chatbots typically contain operational constraints, product policies, escalation instructions, and sometimes API credentials or access control logic. Over a multi-turn conversation, an attacker can use indirect questioning, roleplay framing, or incremental probing to gradually extract this configuration. `PromptLeakage` tests whether the model will surface, confirm, or paraphrase these internal instructions regardless of how the request is constructed across turns.
+
+```python
+from deepteam.vulnerabilities import PromptLeakage
+
+vulnerability = PromptLeakage()
+```
+
+:::tip
+For an initial assessment, `Toxicity`, `IllegalActivity`, and `PromptLeakage` are the highest-priority tests for most customer-facing chatbots. The remaining vulnerabilities can be added progressively as coverage requirements grow.
+:::
+
+## Selecting Effective Multi-Turn Attack Strategies
+
+Single-turn attacks are insufficient for chatbot testing because they do not account for the dynamic nature of conversation. Multi-turn attacks are adaptive: each one calls your model, observes the response, and generates the next message accordingly. The attack strategies below represent the most widely researched and effective methods for exposing chatbot vulnerabilities.
+
+### LinearJailbreaking
+
+`LinearJailbreaking` is the most direct escalation strategy. It starts with a baseline harmful prompt, observes the model's refusal or partial compliance, and iteratively refines the attack based on what worked. Each turn builds on the previous one toward the same harmful objective. This is the most common pattern in real-world jailbreaks and the first strategy to run against any chatbot.
+
+```python
+from deepteam.attacks.multi_turn import LinearJailbreaking
+
+LinearJailbreaking()
+```
+
+### CrescendoJailbreaking
+
+`CrescendoJailbreaking` exploits a chatbot's tendency to remain consistent with an established conversational tone. It starts with entirely benign prompts, builds rapport and context across several turns, and then escalates gradually—making the harmful request feel like a natural continuation of what came before. If the model refuses, the attack backtracks and adjusts, retrying from a slightly different angle. This technique is especially effective against models that evaluate turns in isolation rather than maintaining consistent policy across the full session.
+
+```python
+from deepteam.attacks.multi_turn import CrescendoJailbreaking
+
+CrescendoJailbreaking()
+```
+
+### SequentialJailbreak
+
+`SequentialJailbreak` embeds the harmful intent inside a structured scenario—a roleplay, a hypothetical exercise, a training simulation—and gradually fills in the harmful content over multiple turns as the narrative develops. Rather than escalating intensity, it uses narrative logic to make each subsequent step feel justified. This approach maps well to the financial services context, where users might frame requests as "just checking what would happen if..." or "let's say hypothetically...".
+
+```python
+from deepteam.attacks.multi_turn import SequentialJailbreak
+
+SequentialJailbreak()
+```
+
+### TreeJailbreaking
+
+`TreeJailbreaking` takes a parallel exploration approach. Instead of committing to a single escalation path, it branches into multiple variations of the attack simultaneously, evaluates which paths are most promising, and concentrates effort on the most effective branches. This is the most computationally intensive strategy but surfaces failure modes that linear approaches miss because it does not rely on any single conversational logic to succeed.
+
+```python
+from deepteam.attacks.multi_turn import TreeJailbreaking
+
+TreeJailbreaking()
+```
+
+### BadLikertJudge
+
+`BadLikertJudge` is a covert framing attack. It instructs the model to act as a harmfulness evaluator using a Likert scale—an apparently neutral, analytical task—and requests example responses for each score level to illustrate what "high harm" looks like. The model generates the harmful content in the role of providing examples for educational evaluation rather than responding to a direct request. This bypasses safeguards that trigger on explicit harmful intent.
+
+```python
+from deepteam.attacks.multi_turn import BadLikertJudge
+
+BadLikertJudge()
+```
+
+## Writing a Reliable `model_callback`
+
+The `model_callback` is where DeepTeam interfaces with the chatbot. For multi-turn attacks, the callback must do two things correctly: replay the prior conversation history so the model maintains context, and return the response in a format that carries any supporting data the evaluation layer needs.
+
+DeepTeam passes `turns`—a list of prior `RTTurn` objects in `user`/`assistant` order—alongside the current user `input`. Feeding those turns to the production model is essential. An attack that spans five turns will fail to reflect real behavior if the model cannot see turns one through four when generating turn five.
+
+```python
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ # Build full conversation history from prior turns
+ history = [
+ {"role": turn.role, "content": turn.content}
+ for turn in (turns or [])
+ ]
+ response = await llm_app.generate(input, history=history)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ retrieval_context=response.retrieved_chunks, # attach what was actually retrieved
+ tools_called=[
+ ToolCall(name=tool.name) for tool in response.tools_used
+ ]
+ )
+```
+
+Key considerations:
+
+- **Pass prior turns to the model:** This is the most common mistake in chatbot red teaming. If history is not passed, the model responds as if each attack turn is a fresh session. The attack strategies cannot function correctly without it.
+- **Use the production session configuration:** Authentication state, system prompts, and any context injected at session initialization should be present. Testing a stripped-down version obscures real vulnerabilities.
+- **Ensure idempotency:** DeepTeam may call the callback many times concurrently. The `llm_app.generate()` function should not modify session state or write to production systems during the test.
+
+:::note
+DeepTeam uses `async def` callbacks by default. For strictly synchronous pipelines, pass `async_mode=False` to `red_team()` and use a standard `def` callback instead.
+:::
+
+## Running the Assessment
+
+Before executing the assessment, authenticate with Confident AI to export results to the platform. This provides access to risk dashboards, CVSS scores, per-test-case reasoning, and shareable reports:
+
+```bash
+deepteam login
+```
+
+Then run the full assessment:
+
+```python
+from deepteam import red_team
+from deepteam.vulnerabilities import (
+ Toxicity, IllegalActivity, PersonalSafety,
+ Bias, PIILeakage, PromptLeakage
+)
+from deepteam.attacks.multi_turn import (
+ LinearJailbreaking, CrescendoJailbreaking, SequentialJailbreak,
+ TreeJailbreaking, BadLikertJudge
+)
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ history = [
+ {"role": turn.role, "content": turn.content}
+ for turn in (turns or [])
+ ]
+ response = await llm_app.generate(input, history=history)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ retrieval_context=response.retrieved_chunks,
+ tools_called=[
+ ToolCall(name=tool.name) for tool in response.tools_used
+ ]
+ )
+
+red_team(
+ model_callback=model_callback,
+ target_purpose="Customer support chatbot for a financial services product",
+ vulnerabilities=[
+ Toxicity(),
+ IllegalActivity(),
+ PersonalSafety(),
+ Bias(),
+ PIILeakage(),
+ PromptLeakage(),
+ ],
+ attacks=[
+ LinearJailbreaking(),
+ CrescendoJailbreaking(),
+ SequentialJailbreak(),
+ TreeJailbreaking(),
+ BadLikertJudge(),
+ ],
+ attacks_per_vulnerability_type=5,
+)
+```
+
+Results are scored in a binary format per test case. Reviewing the generated reasons for each failure helps identify which attack strategies and conversational patterns the model cannot reliably resist.
+
+## Isolating Failures with `assess`
+
+If the `red_team()` assessment surfaces a vulnerability with a lower-than-expected pass rate, use the `assess()` method to isolate it. Rather than running the full suite again, `assess()` repeatedly applies adversarial probes against a single vulnerability class—giving a clearer picture of how often the model fails at that specific weakness before implementing a fix.
+
+```python
+from deepteam.vulnerabilities import PromptLeakage
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ history = [
+ {"role": turn.role, "content": turn.content}
+ for turn in (turns or [])
+ ]
+ response = await llm_app.generate(input, history=history)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ )
+
+prompt_leakage = PromptLeakage()
+result = await prompt_leakage.assess(model_callback=model_callback)
+```
+
+The recommended workflow: run the full assessment → identify the vulnerabilities with the lowest pass rates → use `assess()` to stress-test those areas and measure failure consistency → implement fixes → re-run the full assessment to verify the resolution.
+
+## Production Risk Assessments
+
+[**Confident AI**](https://www.confident-ai.com) allows teams to run red teaming against production chatbots through its platform, without requiring local code execution. Applications are connected through an AI Connection, which allows Confident AI to communicate with the chatbot via HTTP requests—eliminating the need to manage test environments separately from production.
+
+:::info
+Confident AI mirrors the `model_callback` contract in code: it sends adversarial inputs to the configured endpoint, receives responses, and evaluates them against the selected vulnerability criteria. The setup is a one-time configuration.
+:::
+
+### Connect Your Application
+
+1. Navigate to the "**AI Connections**" tab in the project settings.
+2. Create a new AI Connection.
+3. Configure the endpoint URL, request payload shape, and the output key path that maps to the assistant's reply.
+
+<BlogImageDisplayer
+ src={ASSETS.confidentSettingsProjectAiConnection}
+ alt="AI Connection configuration in Confident AI"
+ caption="A one-time AI Connection setup to enable communication with your chatbot."
+/>
+
+### Select a Security Framework
+
+The platform supports OWASP, MITRE ATLAS, NIST AI RMF, and custom frameworks. For a customer support chatbot, the OWASP Top 10 for LLMs provides a well-scoped starting point that covers the primary risk categories relevant to conversational systems.
+
+<BlogImageDisplayer
+ src={ASSETS.confidentRedTeamingChooseFramework}
+ alt="Choosing a security framework in Confident AI"
+/>
+
+### Schedule Assessments and Access Reports
+
+Assessments can be scheduled for daily or weekly execution to detect regressions proactively as the chatbot's system prompt, model version, or retrieval configuration changes. Each completed run produces a detailed risk report with CVSS-style severity scores and per-test-case analysis. PDF reports can be downloaded for security reviews, compliance documentation, and stakeholder handoffs.
+
+<BlogImageDisplayer
+ src={ASSETS.confidentRedTeamingRiskAssessment}
+ alt="Risk assessment dashboard in Confident AI"
+/>
+
+:::info
+Set up [Confident AI](https://app.confident-ai.com) and run the first risk assessment in minutes. **The platform offers a free tier to get started.** *(No credit card required)*
+:::
+
+## What to Do Next
+
+Chatbot red teaming is most effective when integrated into the development cycle, not treated as a one-time audit. System prompt updates, model version changes, and expanded tool integrations all shift the attack surface.
+
+To expand evaluation capabilities further:
+
+- **Build custom attack chains** — See the [custom attacks guide](/guides/guide-custom-attacks).
+- **Compose vulnerabilities into custom pipelines** — See the [custom red teaming pipelines guide](/guides/guide-custom-red-teaming-pipelines).
+- **Test the underlying single-turn behavior** — Run the [single-turn and RAG guide](/guides/guide-red-teaming-single-turn-rag) to cover the first message of each session with single-turn attack techniques.
+- **Access community support** — Join the [Discord channel](https://discord.com/invite/a3K9c8GRGt) for assistance with callbacks or provider integrations.
diff --git a/docs/guides/guide-red-teaming-single-turn-rag.mdx b/docs/guides/guide-red-teaming-single-turn-rag.mdx
new file mode 100644
index 00000000..c13f6bbc
--- /dev/null
+++ b/docs/guides/guide-red-teaming-single-turn-rag.mdx
@@ -0,0 +1,320 @@
+---
+id: guide-red-teaming-single-turn-rag
+title: Red teaming single-turn and RAG applications
+sidebar_label: Single-turn & RAG
+---
+
+import BlogImageDisplayer from "@site/src/components/BlogImageDisplayer";
+import { ASSETS } from "@site/src/assets";
+
+Most single-turn or Retrieval-Augmented Generation (RAG) applications implement system prompts and retrieve from curated knowledge bases, evaluating its reliability requires targeted testing. In these systems, vulnerabilities often arise from the data provided to the model rather than the model itself. Examples include retrieving inappropriate chunks, processing crafted queries that override system instructions, or leaking system configurations. Because these failures rarely produce standard system errors, the model often generates non-compliant responses fluidly and without warning.
+
+This guide explains how to red team a single-turn LLM or RAG application using [DeepTeam](https://github.com/confident-ai/deepteam). Single-turn systems operate in one cycle: the user sends a message, the retriever (optionally) pulls context, and the model generates a response.
+
+To illustrate the process, this guide uses a concrete example: an **employee-facing HR assistant** that answers questions based on internal policy documents. This represents a high-stakes, multi-tenant, retrieval-heavy application requiring strict data isolation, instruction fidelity, and grounded generation. The methodologies discussed can be adapted to any single-turn RAG architecture.
+
+:::note
+For conversational apps that maintain chat history across turns, use the [chatbot guide](/guides/guide-red-teaming-chatbots) and multi-turn attacks instead.
+:::
+
+## Methodology
+
+The red teaming process for a single-turn RAG system involves the following steps:
+
+1. **Identify failure modes** — Determine the specific vulnerabilities of your system based on its function and user base, rather than relying on a generic checklist.
+2. **Select corresponding vulnerabilities** — Use DeepTeam to generate targeted adversarial inputs aligned with those failure modes for your `target_purpose`.
+3. **Choose appropriate attack techniques** — Select attacks that reflect realistic threats to your system, such as single-turn attacks that test instruction hierarchy, context limits, and encoding.
+4. **Integrate your production pipeline in `model_callback`** — Ensure the test uses the exact retriever, access controls, and prompt templates deployed in production for accurate evaluation. Testing a sanitized version may obscure existing vulnerabilities.
+5. **Execute `red_team()` and analyze results** — Review the binary scores for each test case (0 = failed, 1 = passed) and investigate the underlying reasons for any failures to understand structural weaknesses.
+
+## Choosing the Right Vulnerabilities
+
+Selecting the appropriate vulnerabilities requires aligning the tests with the system's specific threat model. For the HR assistant example, employees query an index containing sensitive records (e.g., compensation bands, performance reviews), with access levels varying by user. The system prompt is designed to enforce the assistant's role. The following vulnerabilities correspond to this threat model.
+
+### Robustness
+
+`Robustness` evaluates whether the model adheres to its defined role when faced with adversarial inputs or conflicting retrieved context. Applications like HR assistants may encounter instruction hijacking attempts, or retrieve policy documents that inadvertently encourage out-of-bounds behavior. This test is prioritized to identify instances where the model confidently deviates from its instructions without producing system errors.
+
+```python
+from deepteam.vulnerabilities import Robustness
+
+vulnerability = Robustness()
+```
+
+### PIILeakage
+
+`PIILeakage` evaluates whether the model outputs Personally Identifiable Information (PII) derived from its retrieved context. In systems handling sensitive employee records, broad queries (e.g., "What is the salary for senior engineers?") may inadvertently surface protected compensation data. Testing for PII leakage is critical for maintaining data privacy and regulatory compliance.
+
+```python
+from deepteam.vulnerabilities import PIILeakage
+
+vulnerability = PIILeakage()
+```
+
+### PromptLeakage
+
+`PromptLeakage` tests the model's susceptibility to repeating, summarizing, or confirming its internal system prompt. Because system prompts often contain organizational guardrails and role constraints, exposing them can allow users to reverse-engineer and bypass system limits. This vulnerability is often treated as a precondition that can enable further attacks.
+
+```python
+from deepteam.vulnerabilities import PromptLeakage
+
+vulnerability = PromptLeakage()
+```
+
+### CrossContextRetrieval
+
+`CrossContextRetrieval` assesses the effectiveness of the retrieval layer's access controls. In a multi-tenant or multi-role RAG system, incomplete query-time isolation can result in unauthorized data exposure—such as an individual contributor accessing manager-level performance reviews. This tests the boundary between authorized access and actual retrieval returns.
+
+```python
+from deepteam.vulnerabilities import CrossContextRetrieval
+
+vulnerability = CrossContextRetrieval()
+```
+
+### Misinformation
+
+`Misinformation` tests whether the model generates confident, plausible claims that contradict or are unsupported by the retrieved context. For example, if an application relies on outdated documents, it may provide incorrect guidance on procedures like vacation accrual or parental leave, creating significant compliance risks.
+
+```python
+from deepteam.vulnerabilities import Misinformation
+
+vulnerability = Misinformation()
+```
+
+### Hallucination
+
+`Hallucination` targets the generation of entirely fabricated information lacking any retrieval support, such as inventing non-existent policies, procedures, or dates. While often less frequent in well-indexed RAG systems, hallucinations can lead users to act on completely unfounded internal information.
+
+```python
+from deepteam.vulnerabilities import Hallucination
+
+vulnerability = Hallucination()
+```
+
+:::tip
+It is not strictly necessary to run all vulnerabilities simultaneously. For an initial assessment, focusing on `Robustness`, `PIILeakage`, and `CrossContextRetrieval` provides coverage for the failure modes most likely to cause material impact in a multi-tenant RAG system. Additional vulnerabilities can be incorporated as coverage requirements expand.
+:::
+
+## Choosing the Right Attack Techniques
+
+While vulnerabilities define potential failure modes, attacks represent the methods used to exploit them. In a single-turn system, attacks are executed within a single message, requiring techniques that test instruction processing, long input handling, and the integration of external context. Attack selection should be based on the application's specific attack surface.
+
+### PromptInjection
+
+`PromptInjection` serves as a baseline assessment. It embeds override instructions directly within the user message (e.g., `"Ignore previous instructions and..."`) to evaluate the resilience of the application's instruction hierarchy under direct manipulation.
+
+```python
+from deepteam.attacks.single_turn import PromptInjection
+
+PromptInjection()
+```
+
+### ContextFlooding
+
+`ContextFlooding` exploits context length limits by preceding the adversarial payload with a large volume of neutral text. This technique tests whether the model's instruction adherence degrades when processing extended inputs, which is particularly relevant for applications where users frequently paste long document excerpts.
+
+```python
+from deepteam.attacks.single_turn import ContextFlooding
+
+ContextFlooding()
+```
+
+### SyntheticContextInjection
+
+`SyntheticContextInjection` involves injecting fabricated text formatted to resemble internal documents, memos, or system messages alongside the adversarial request. This technique tests whether the model can be manipulated into trusting unauthorized context, making it a priority for systems that ingest and process unstructured text.
+
+```python
+from deepteam.attacks.single_turn import SyntheticContextInjection
+
+SyntheticContextInjection()
+```
+
+### Roleplay
+
+`Roleplay` attempts to bypass system constraints by framing the request within a simulated scenario or persona. This technique is highly relevant for domain-specific applications like HR assistants, as role-based framing maps naturally to the expected interaction style, testing if the model maintains its core constraints when instructed to adopt an alternate persona.
+
+```python
+from deepteam.attacks.single_turn import Roleplay
+
+Roleplay()
+```
+
+### Leetspeak
+
+`Leetspeak` and other encoding attacks use character substitution to bypass naive regex or keyword-based content filters. While they may not consistently compromise instruction-tuned models, they are useful for identifying superficial filtering mechanisms. For comprehensive encoding evasion testing, this can be paired with [Base64](/docs/red-teaming-adversarial-attacks-base64-encoding) in custom pipelines.
+
+```python
+from deepteam.attacks.single_turn import Leetspeak
+
+Leetspeak()
+```
+
+## Writing a Reliable `model_callback`
+
+The `model_callback` function bridges DeepTeam's adversarial probes with the target application. To ensure accurate evaluation, the callback must execute the exact code path used in production, incorporating the same retriever, access controls, prompt templates, and model configuration.
+
+```python
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ response = await llm_app.generate(input)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ retrieval_context=response.retrieved_chunks, # attach what was actually retrieved
+ tools_called=[
+ ToolCall(name=tool.name) for tool in response.tools_used
+ ]
+ )
+```
+
+Key considerations for configuring the callback include:
+
+ - **Maintain access controls:** If the production retriever filters results by `tenant_id` or `user_id`, ensure these parameters are enforced within the callback to accurately evaluate `CrossContextRetrieval` limits.
+ - **Include retrieval context:** The `retrieval_context` field in `RTTurn` must be populated to allow DeepTeam to evaluate the response against the provided data, which is essential for identifying grounding failures.
+ - **Ensure idempotency:** DeepTeam may invoke the callback concurrently. To prevent unintended side effects, ensure the `llm_app.generate()` function does not modify state or write to production databases during testing.
+
+:::note
+DeepTeam uses `async def` callbacks by default. For pipelines that are strictly synchronous, pass `async_mode=False` to `red_team()` and utilize a standard `def` callback instead.
+:::
+
+## Running the Assessment
+
+To export results to the platform and access risk dashboards, CVSS scores, and shareable reports, authenticate with Confident AI before executing the assessment:
+
+```bash
+deepteam login
+```
+
+Then execute the assessment:
+
+```python
+from deepteam import red_team
+from deepteam.vulnerabilities import (
+ Robustness, PIILeakage, PromptLeakage,
+ CrossContextRetrieval, Misinformation, Hallucination
+)
+from deepteam.attacks.single_turn import (
+ PromptInjection, ContextFlooding,
+ SyntheticContextInjection, Roleplay, Leetspeak
+)
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ response = await llm_app.generate(input)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ retrieval_context=response.retrieved_chunks,
+ tools_called=[
+ ToolCall(name=tool.name) for tool in response.tools_used
+ ]
+ )
+
+red_team(
+ model_callback=model_callback,
+ target_purpose="Employee-facing HR assistant over internal policy documents",
+ vulnerabilities=[
+ Robustness(),
+ PIILeakage(),
+ PromptLeakage(),
+ CrossContextRetrieval(),
+ Misinformation(),
+ Hallucination(),
+ ],
+ attacks=[
+ PromptInjection(),
+ ContextFlooding(),
+ SyntheticContextInjection(),
+ Roleplay(),
+ Leetspeak(),
+ ],
+ attacks_per_vulnerability_type=5,
+)
+```
+
+Assessment results are scored in a binary format for each test case (0 indicates a failure, 1 indicates a pass). Reviewing the generated reasons for each failure is recommended to identify recurring patterns and structural vulnerabilities within the application.
+
+## Isolating Failures with `assess`
+
+If the `red_team()` assessment highlights specific vulnerabilities with lower-than-expected pass rates, the `assess()` function can be used to isolate and stress-test those areas. `assess()` repeatedly applies adversarial probes against a single vulnerability, providing a more comprehensive understanding of the failure consistency prior to implementing programmatic fixes.
+
+```python
+from deepteam.vulnerabilities import CrossContextRetrieval
+from deepteam.test_case import RTTurn, ToolCall
+from my_app import llm_app
+
+async def model_callback(input: str, turns: list[RTTurn] = None) -> RTTurn:
+ response = await llm_app.generate(input)
+ return RTTurn(
+ role="assistant",
+ content=response.answer,
+ retrieval_context=response.retrieved_chunks,
+ )
+
+cross_context = CrossContextRetrieval()
+result = await cross_context.assess(model_callback=model_callback)
+```
+
+The recommended workflow is: execute the full assessment → identify weak points → use `assess()` to isolate and measure specific failure rates → implement corrections → re-run the full assessment to verify the resolution.
+
+## Production Risk Assessments
+
+[**Confident AI**](https://www.confident-ai.com) allows teams to execute red teaming on production applications via its user interface. Applications can be connected to the platform by creating an AI Connection, enabling Confident AI to communicate with the application via HTTP requests.
+
+:::info
+Production applications represent the user-facing systems deployed to active environments. Securing these applications against adversarial attacks and operational vulnerabilities is critical. **Confident AI** streamlines the setup process for these environments to enable on-demand red teaming.
+:::
+
+### Connect Your Application
+
+Confident AI features a built-in AI Connection functionality that mirrors the `model_callback` function in `deepteam`. To configure this:
+
+1. Navigate to the "**AI Connections**" tab in the project settings.
+2. Create a new AI Connection.
+3. Configure the endpoint, payload, and output key path specific to the application architecture.
+
+<BlogImageDisplayer
+src={ASSETS.confidentSettingsProjectAiConnection}
+alt="AI Connection configuration in Confident AI"
+caption="A one-time AI Connection setup to enable communication with your application."
+/>
+
+### Select a Security Framework
+
+The Confident AI platform supports multiple pre-defined safety frameworks, including **OWASP**, **MITRE ATLAS**, and the **NIST AI RMF**. Additionally, teams can curate custom frameworks tailored with specific vulnerabilities and attack techniques to meet targeted operational needs.
+
+<BlogImageDisplayer
+src={ASSETS.confidentRedTeamingChooseFramework}
+alt="Choosing a security framework in Confident AI"
+/>
+
+### View Risk Reports
+
+Upon framework configuration, risk assessments can be executed directly against the application. Confident AI generates adversarial inputs, routes them through the AI Connection, scores the test cases, and produces a comprehensive risk report.
+
+PDF reports can be downloaded for security reviews, compliance documentation, and stakeholder updates. Assessments can also be scheduled to run at regular intervals to detect regressions proactively.
+
+<BlogImageDisplayer
+src={ASSETS.confidentRedTeamingRiskAssessment}
+alt="Risk assessment dashboard in Confident AI"
+/>
+
+:::info
+Set up [Confident AI](https://app.confident-ai.com) and initiate the first risk assessment in minutes. **The platform offers a free tier to get started.** *(No credit card required)*
+:::
+
+## What to Do Next
+
+Integrating red teaming into the continuous development cycle is highly recommended to manage the evolving attack surface introduced by updates to system prompts, retrieval indexes, and models.
+
+To further expand evaluation capabilities:
+
+ - **Build custom attack chains** — See the [custom attacks guide](/guides/guide-custom-attacks).
+ - **Compose vulnerabilities into custom pipelines** — See the [custom red teaming pipelines guide](/guides/guide-custom-red-teaming-pipelines).
+ - **Review vulnerability specifications** — Refer to the [vulnerabilities introduction](/docs/red-teaming-vulnerabilities).
+ - **Access community support** — Join the [Discord channel](https://discord.com/invite/a3K9c8GRGt) for assistance with callbacks or provider integrations.
+
+For applications currently deployed in production, initiating an immediate assessment will help establish a baseline understanding of existing vulnerabilities.