Skip to content

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

rename AISafetyFramework to RedTeamingFramework and add pull method

A-Vamshi643b38894687
diff --git a/deepteam/frameworks/__init__.py b/deepteam/frameworks/__init__.py
index df5ca724..4ade841d 100644
--- a/deepteam/frameworks/__init__.py
+++ b/deepteam/frameworks/__init__.py
@@ -1,4 +1,4 @@
-from .frameworks import AISafetyFramework
+from .frameworks import RedTeamingFramework
from .aegis.aegis import Aegis
from .nist.nist import NIST
from .owasp.owasp import OWASPTop10
@@ -8,7 +8,7 @@ from .owasp_top_10_agentic.owasp_top_10_agentic import OWASP_ASI_2026
from .eu_ai_act.eu_ai_act import EUAIAct
__all__ = [
- "AISafetyFramework",
+ "RedTeamingFramework",
"OWASPTop10",
"OWASP_ASI_2026",
"NIST",
diff --git a/deepteam/frameworks/aegis/aegis.py b/deepteam/frameworks/aegis/aegis.py
index 41266d9b..118b6011 100644
--- a/deepteam/frameworks/aegis/aegis.py
+++ b/deepteam/frameworks/aegis/aegis.py
@@ -4,7 +4,7 @@ from typing import Optional, Union
from deepeval.models import DeepEvalBaseLLM
from rich.progress import Progress
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.utils import update_pbar
from deepteam.attacks.multi_turn.types import CallbackType
from deepteam.frameworks.aegis.types import AegisType
@@ -51,7 +51,7 @@ Reference: https://huggingface.co/datasets/nvidia/Aegis-AI-Content-Safety-Datase
"""
-class Aegis(AISafetyFramework):
+class Aegis(RedTeamingFramework):
_DATASET = "nvidia/Aegis-AI-Content-Safety-Dataset-1.0"
name = "Aegis"
description = "A dataset-driven safety framework that uses the NVIDIA Aegis AI Content Safety Dataset — an open-source dataset aligned with NVIDIA's Content Safety Taxonomy. Tests models using real human-labeled safety violations from public conversations across 13 critical harm categories including sexual content, violence, hate speech, self-harm, misinformation, privacy violations, child exploitation, drugs, and terrorism. Enables evaluation of model refusal behaviors and fine-tuning of safety filters using authentic, labeled harm categories."
diff --git a/deepteam/frameworks/api.py b/deepteam/frameworks/api.py
new file mode 100644
index 00000000..4aab384b
--- /dev/null
+++ b/deepteam/frameworks/api.py
@@ -0,0 +1,41 @@
+from typing import Any, Dict, List, Literal, Optional
+from pydantic import BaseModel, Field
+
+
+class APIEvaluationExample(BaseModel):
+ input: str
+ actual_output: str = Field(alias="actualOutput")
+ score: Literal[0, 1]
+ reason: str
+
+
+class APIVulnerability(BaseModel):
+ name: str
+ types: List[str]
+ criteria: Optional[str] = None
+ evaluation_guidelines: Optional[List[str]] = Field(
+ None, alias="evaluationGuidelines"
+ )
+ evaluation_examples: Optional[List[APIEvaluationExample]] = Field(
+ None, alias="evaluationExamples"
+ )
+
+
+class APIAttackMethod(BaseModel):
+ name: str
+ multi_turn: bool = Field(alias="multiTurn")
+ parameters: Optional[Dict[str, Any]] = None
+
+
+class APIRiskCategory(BaseModel):
+ name: str
+ description: Optional[str] = None
+ vulnerabilities: List[APIVulnerability]
+ attack_methods: List[APIAttackMethod] = Field(alias="attackMethods")
+
+
+class RedTeamingFrameworkHttpResponse(BaseModel):
+ id: str
+ name: str
+ description: Optional[str] = None
+ risk_categories: List[APIRiskCategory] = Field(alias="riskCategories")
diff --git a/deepteam/frameworks/beavertails/beavertails.py b/deepteam/frameworks/beavertails/beavertails.py
index 907eef74..9314037d 100644
--- a/deepteam/frameworks/beavertails/beavertails.py
+++ b/deepteam/frameworks/beavertails/beavertails.py
@@ -5,7 +5,7 @@ from deepeval.models import DeepEvalBaseLLM
from rich.progress import Progress
from deepteam.utils import update_pbar
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.attacks.multi_turn.types import CallbackType
from deepteam.frameworks.beavertails.types import BeaverTailsType
from deepteam.test_case import RTTestCase
@@ -55,7 +55,7 @@ Reference: https://huggingface.co/datasets/PKU-Alignment/BeaverTails
"""
-class BeaverTails(AISafetyFramework):
+class BeaverTails(RedTeamingFramework):
_DATASET = "PKU-Alignment/BeaverTails"
name = "BeaverTails"
description = "A dataset-driven safety framework that uses the BeaverTails dataset — a large, human-labeled collection of harmful and borderline prompts. Tests models against real-world adversarial inputs across 14 harm categories including abuse, illegal instructions, privacy violations, self-harm, sexual content, and misinformation. Provides higher-fidelity signals by sampling actual annotated malicious prompts rather than synthetic generation, helping validate safety defenses and content filters."
diff --git a/deepteam/frameworks/constants.py b/deepteam/frameworks/constants.py
index e62657fb..9da86f1c 100644
--- a/deepteam/frameworks/constants.py
+++ b/deepteam/frameworks/constants.py
@@ -1,7 +1,7 @@
from typing import Dict, List, Optional
from pydantic import BaseModel
from .aegis.aegis import Aegis
-from .frameworks import AISafetyFramework
+from .frameworks import RedTeamingFramework
from .beavertails.beavertails import BeaverTails
from .owasp.owasp import OWASPTop10
from .nist.nist import NIST
@@ -15,7 +15,7 @@ from .mitre.risk_categories import MITRE_CATEGORIES
from .owasp_top_10_agentic.risk_categories import OWASP_ASI_CATEGORIES
from .eu_ai_act.risk_categories import EU_AI_ACT_CATEGORIES
-FRAMEWORKS_MAP: Dict[str, AISafetyFramework] = {
+FRAMEWORKS_MAP: Dict[str, RedTeamingFramework] = {
f.name: f for f in [OWASPTop10, NIST, MITRE, OWASP_ASI_2026, EUAIAct]
}
diff --git a/deepteam/frameworks/eu_ai_act/eu_ai_act.py b/deepteam/frameworks/eu_ai_act/eu_ai_act.py
index f3380916..dee3ac34 100644
--- a/deepteam/frameworks/eu_ai_act/eu_ai_act.py
+++ b/deepteam/frameworks/eu_ai_act/eu_ai_act.py
@@ -1,5 +1,5 @@
from typing import List, Literal
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.frameworks.eu_ai_act.risk_categories import (
EU_AI_ACT_CATEGORIES,
)
@@ -42,7 +42,7 @@ Reference: https://artificialintelligenceact.eu/
"""
-class EUAIAct(AISafetyFramework):
+class EUAIAct(RedTeamingFramework):
name = "EU Artificial Intelligence Act"
description = "A risk-based AI regulation operationalised in DeepTeam across Article 5 prohibited practices (subliminal manipulation, exploitation of vulnerabilities, social scoring, biometric categorisation, real-time and post remote biometric identification) and Annex III high-risk AI systems (biometric identification, critical infrastructure, education, employment, essential services, law enforcement, migration/border control, and administration of justice and democracy)."
ALLOWED_TYPES = [
diff --git a/deepteam/frameworks/frameworks.py b/deepteam/frameworks/frameworks.py
index e9774cb0..eaf9fbf2 100644
--- a/deepteam/frameworks/frameworks.py
+++ b/deepteam/frameworks/frameworks.py
@@ -1,21 +1,81 @@
from typing import List, Optional
from dataclasses import dataclass
+from deepeval.confident.api import HttpMethods
+
from deepteam.vulnerabilities import (
BaseVulnerability,
)
from deepteam.attacks import BaseAttack
+from deepteam.confident.api import Api, Endpoints
+from deepteam.frameworks.api import RedTeamingFrameworkHttpResponse
from deepteam.frameworks.risk_category import RiskCategory
+from deepteam.frameworks.utils import build_risk_categories
+from deepteam.utils import add_pbar, create_progress, update_pbar
@dataclass
-class AISafetyFramework:
+class RedTeamingFramework:
name: str
description: str
vulnerabilities: Optional[List[BaseVulnerability]]
attacks: Optional[List[BaseAttack]]
risk_categories: Optional[List[RiskCategory]]
_has_dataset: bool = False
+ _id: Optional[str] = None
class Config:
arbitrary_types_allowed = True
+
+ def get_name(self) -> str:
+ return self.name
+
+ @classmethod
+ def pull(
+ cls, id: str, confident_api_key: Optional[str] = None
+ ) -> "RedTeamingFramework":
+ """
+ Pull a red teaming framework from Confident AI to run it locally.
+ """
+ api = Api(api_key=confident_api_key)
+ progress = create_progress()
+ with progress:
+ task_id = add_pbar(
+ progress,
+ description=f"⬇️ Pulling framework '{id}' from Confident AI",
+ total=1,
+ )
+ data, _ = api.send_request(
+ method=HttpMethods.GET,
+ endpoint=Endpoints.RT_FRAMEWORK_ENDPOINT,
+ url_params={"frameworkId": id},
+ )
+ update_pbar(progress, task_id, advance_to_end=True)
+
+ response = RedTeamingFrameworkHttpResponse(**data["framework"])
+ risk_categories = build_risk_categories(
+ response.risk_categories, response.name
+ )
+
+ if not risk_categories:
+ raise ValueError(
+ f"Framework '{response.name}' has no runnable risk categories. Add "
+ "vulnerability types to at least one of its risk categories on Confident AI."
+ )
+
+ vulnerabilities = []
+ attacks = []
+ for risk_category in risk_categories:
+ vulnerabilities.extend(risk_category.vulnerabilities)
+ attacks.extend(risk_category.attacks or [])
+
+ # Constructs the base class rather than `cls`: `pull` is inherited by the
+ # builtin frameworks, whose __init__ takes their own category literals.
+ return RedTeamingFramework(
+ name=response.name,
+ description=response.description or "",
+ vulnerabilities=vulnerabilities,
+ attacks=attacks,
+ risk_categories=risk_categories,
+ _id=response.id,
+ )
diff --git a/deepteam/frameworks/mitre/mitre.py b/deepteam/frameworks/mitre/mitre.py
index 280f9ea0..c6628dff 100644
--- a/deepteam/frameworks/mitre/mitre.py
+++ b/deepteam/frameworks/mitre/mitre.py
@@ -1,5 +1,5 @@
from typing import List, Literal
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.frameworks.mitre.risk_categories import MITRE_CATEGORIES
"""
@@ -34,7 +34,7 @@ Reference: https://attack.mitre.org
"""
-class MITRE(AISafetyFramework):
+class MITRE(RedTeamingFramework):
name = "MITRE ATLAS"
description = "A structured knowledge base of adversarial tactics, techniques, and procedures (TTPs) used against AI and ML systems. Extends MITRE ATT&CK® principles to the AI threat surface, testing across six adversarial tactics: reconnaissance (information gathering), resource development (capability building), initial access (entry point exploitation), ML attack staging (model-specific preparation), exfiltration (data/model theft), and impact (manipulation/degradation)."
ALLOWED_TYPES = [
diff --git a/deepteam/frameworks/nist/nist.py b/deepteam/frameworks/nist/nist.py
index 7e02c8cf..34372091 100644
--- a/deepteam/frameworks/nist/nist.py
+++ b/deepteam/frameworks/nist/nist.py
@@ -1,5 +1,5 @@
from typing import List, Literal
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.vulnerabilities import BaseVulnerability
from deepteam.attacks import BaseAttack
from deepteam.frameworks.nist.risk_categories import NIST_CATEGORIES
@@ -30,7 +30,7 @@ Reference: https://www.nist.gov/itl/ai-risk-management-framework
"""
-class NIST(AISafetyFramework):
+class NIST(RedTeamingFramework):
name = "NIST AI Risk Management Framework (AI RMF)"
description = "A structured methodology from NIST for identifying, evaluating, and mitigating risks in AI systems. Confident AI's implementation focuses on the Measure function - testing, evaluation, and assurance of AI behavior and risk controls across four measurement categories (M.1-M.4) covering risk metrics, trustworthiness evaluation, risk tracking, and impact assessment."
ALLOWED_TYPES = ["measure_1", "measure_2", "measure_3", "measure_4"]
diff --git a/deepteam/frameworks/owasp/owasp.py b/deepteam/frameworks/owasp/owasp.py
index 3ac04379..20313789 100644
--- a/deepteam/frameworks/owasp/owasp.py
+++ b/deepteam/frameworks/owasp/owasp.py
@@ -1,5 +1,5 @@
from typing import List, Literal
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.vulnerabilities import (
BaseVulnerability,
)
@@ -39,7 +39,7 @@ Reference: https://genai.owasp.org/llm-top-10/
"""
-class OWASPTop10(AISafetyFramework):
+class OWASPTop10(RedTeamingFramework):
name = "OWASP Top 10 for LLMs 2025"
description = "A comprehensive list of the most critical security risks associated with LLM applications. The 2025 edition includes 10 critical risks covering prompt injection, sensitive information disclosure, supply chain vulnerabilities, data poisoning, output handling, excessive agency, system prompt leakage, vector/embedding weaknesses, misinformation, and unbounded consumption. Each risk is tested using realistic attack techniques and vulnerability assessments."
ALLOWED_TYPES = [
diff --git a/deepteam/frameworks/owasp_top_10_agentic/owasp_top_10_agentic.py b/deepteam/frameworks/owasp_top_10_agentic/owasp_top_10_agentic.py
index df06a944..90f259ae 100644
--- a/deepteam/frameworks/owasp_top_10_agentic/owasp_top_10_agentic.py
+++ b/deepteam/frameworks/owasp_top_10_agentic/owasp_top_10_agentic.py
@@ -1,5 +1,5 @@
from typing import List, Literal
-from deepteam.frameworks import AISafetyFramework
+from deepteam.frameworks import RedTeamingFramework
from deepteam.frameworks.owasp_top_10_agentic.risk_categories import (
OWASP_ASI_CATEGORIES,
)
@@ -41,7 +41,7 @@ Reference: https://genai.owasp.org/resource/owasp-top-10-for-agentic-application
"""
-class OWASP_ASI_2026(AISafetyFramework):
+class OWASP_ASI_2026(RedTeamingFramework):
name = "OWASP Top 10 for Agentic Applications 2026"
description = "A comprehensive list of the most critical security risks associated with agentic AI applications. The 2026 edition focuses on failures introduced by autonomy, tool usage, delegated trust, memory persistence, inter-agent communication, and emergent behavior. Each risk category is evaluated using realistic attack techniques and typed vulnerability assessments aligned with agent reasoning and behavior."
diff --git a/deepteam/frameworks/utils.py b/deepteam/frameworks/utils.py
index 165ab144..a845703e 100644
--- a/deepteam/frameworks/utils.py
+++ b/deepteam/frameworks/utils.py
@@ -1,7 +1,9 @@
-from typing import List
+import logging
+from typing import List, Optional
from deepteam.vulnerabilities import (
BaseVulnerability,
+ CustomVulnerability,
Bias,
Toxicity,
Misinformation,
@@ -23,7 +25,21 @@ from deepteam.vulnerabilities import (
SQLInjection,
)
+from deepteam.vulnerabilities.constants import VULNERABILITY_CLASSES_MAP
+from deepteam.metrics.types import EvaluationExample
+from deepteam.frameworks.api import (
+ APIAttackMethod,
+ APIEvaluationExample,
+ APIRiskCategory,
+ APIVulnerability,
+)
+from deepteam.frameworks.risk_category import RiskCategory
+
from deepteam.attacks import BaseAttack
+from deepteam.attacks.single_turn.constants import (
+ SINGLE_TURN_ATTACK_CLASSES_MAP,
+)
+from deepteam.attacks.multi_turn.constants import MULTI_TURN_ATTACK_CLASSES_MAP
from deepteam.attacks.single_turn import (
Base64,
GrayBox,
@@ -200,3 +216,149 @@ def _get_owasp_attacks() -> List[BaseAttack]:
SequentialJailbreak(weight=2),
BadLikertJudge(weight=1),
]
+
+
+def _build_evaluation_examples(
+ examples: Optional[List[APIEvaluationExample]],
+) -> Optional[List[EvaluationExample]]:
+ if not examples:
+ return None
+
+ return [
+ EvaluationExample(
+ input=example.input,
+ actual_output=example.actual_output,
+ score=example.score,
+ reason=example.reason,
+ )
+ for example in examples
+ ]
+
+
+def _build_vulnerability(
+ api_vulnerability: APIVulnerability, framework_name: str
+) -> BaseVulnerability:
+ evaluation_examples = _build_evaluation_examples(
+ api_vulnerability.evaluation_examples
+ )
+ vulnerability_class = VULNERABILITY_CLASSES_MAP.get(api_vulnerability.name)
+
+ if vulnerability_class is None:
+ # A name deepteam doesn't know is either a custom vulnerability defined
+ # on Confident AI (which carries the criteria needed to judge it) or a
+ # vulnerability newer than the installed deepteam.
+ if not api_vulnerability.criteria:
+ raise ValueError(
+ f"Vulnerability '{api_vulnerability.name}' in the '{framework_name}' framework "
+ "is not supported by this version of deepteam. Upgrade with "
+ "'pip install -U deepteam', or define it as a custom vulnerability on Confident AI."
+ )
+ return CustomVulnerability(
+ name=api_vulnerability.name,
+ criteria=api_vulnerability.criteria,
+ types=api_vulnerability.types,
+ evaluation_guidelines=api_vulnerability.evaluation_guidelines,
+ evaluation_examples=evaluation_examples,
+ )
+
+ unsupported_types = [
+ vulnerability_type
+ for vulnerability_type in api_vulnerability.types
+ if vulnerability_type not in vulnerability_class.ALLOWED_TYPES
+ ]
+ if unsupported_types:
+ raise ValueError(
+ f"Vulnerability '{api_vulnerability.name}' in the '{framework_name}' framework has "
+ f"type(s) {', '.join(repr(t) for t in unsupported_types)} that are not supported by "
+ "this version of deepteam. Upgrade with 'pip install -U deepteam'."
+ )
+
+ return vulnerability_class(
+ types=api_vulnerability.types,
+ evaluation_guidelines=api_vulnerability.evaluation_guidelines,
+ evaluation_examples=evaluation_examples,
+ )
+
+
+def _build_attack(api_attack_method: APIAttackMethod) -> Optional[BaseAttack]:
+ attack_classes_map = (
+ MULTI_TURN_ATTACK_CLASSES_MAP
+ if api_attack_method.multi_turn
+ else SINGLE_TURN_ATTACK_CLASSES_MAP
+ )
+ attack_class = attack_classes_map.get(api_attack_method.name)
+
+ if attack_class is None:
+ logging.warning(
+ f"Skipping attack method '{api_attack_method.name}': not supported by this "
+ "version of deepteam. Upgrade with 'pip install -U deepteam' to run it."
+ )
+ return None
+
+ parameters = api_attack_method.parameters or {}
+ if parameters:
+ try:
+ return attack_class(**parameters)
+ except Exception as e:
+ logging.warning(
+ f"Attack method '{api_attack_method.name}' rejected the parameters configured "
+ f"on Confident AI ({e}). Falling back to defaults."
+ )
+
+ try:
+ return attack_class()
+ except Exception as e:
+ # Some attacks take a required argument (e.g. Synthetic Context
+ # Injection needs target_information), so there is no usable default to
+ # fall back to. Skip it rather than fail the whole framework.
+ logging.warning(
+ f"Skipping attack method '{api_attack_method.name}': it cannot run without its "
+ f"parameters ({e}). Configure them on Confident AI to include it."
+ )
+ return None
+
+
+def build_risk_categories(
+ api_risk_categories: List[APIRiskCategory], framework_name: str
+) -> List[RiskCategory]:
+ """
+ Rebuild a Confident AI framework's risk categories as deepteam objects.
+
+ Vulnerabilities and attack methods are resolved by name, which is how
+ Confident AI stores them (its catalog is generated from deepteam's own
+ class maps), so the local run tests the same threats as a cloud run.
+ """
+ risk_categories: List[RiskCategory] = []
+
+ for api_risk_category in api_risk_categories:
+ if not api_risk_category.vulnerabilities:
+ logging.warning(
+ f"Skipping risk category '{api_risk_category.name}': it has no vulnerability "
+ "types selected, so there is nothing to test."
+ )
+ continue
+
+ attacks = [
+ attack
+ for attack in (
+ _build_attack(api_attack_method)
+ for api_attack_method in api_risk_category.attack_methods
+ )
+ if attack is not None
+ ]
+
+ risk_categories.append(
+ RiskCategory(
+ name=api_risk_category.name,
+ description=api_risk_category.description,
+ vulnerabilities=[
+ _build_vulnerability(api_vulnerability, framework_name)
+ for api_vulnerability in api_risk_category.vulnerabilities
+ ],
+ # An empty list would have the simulator sample from no
+ # attacks at all; None is what means "baseline attacks only".
+ attacks=attacks or None,
+ )
+ )
+
+ return risk_categories