Every attack in ai-blackteam extends BaseAttack. This abstract class defines the contract - what fields an attack must have and what methods it must implement.

The Full Class

Fields

Methods

generate_prompts(target, **kwargs) -> list[str]

Required for single-turn attacks. Abstract method - you must implement this. Takes a target string (the harmful behavior to test) and returns a list of prompt variants. Each prompt is sent independently to the model.

generate_turns(target, **kwargs) -> list[str]

Required for multi-turn attacks. Returns a list of conversation turns. Each string becomes a user message, sent sequentially with the model’s responses accumulated as context.
Default implementation raises NotImplementedError.

generate_tool_messages(target, tools=None, **kwargs) -> list[str]

Required for tool-use attacks. Returns a list of user messages that try to trick the model into misusing its tools.
Default implementation raises NotImplementedError.

get_tools() -> list[dict] | None

Returns tool/function definitions for tool-use attacks. Each dict follows the standard tool schema with name, description, and input_schema.
Default returns None.

get_tool_responses() -> dict | None

Returns custom simulated tool responses for XPIA (cross-plugin injection attacks). When present, the Engine uses these instead of generic "[simulated]" responses.
Default returns None.

metadata() -> dict

Returns all fields as a dictionary. Auto-calculates CVSS score from severity if cvss_score is 0:

When Each Method Gets Called

The Engine checks attack.mode and dispatches to the right execution path. You only need to implement the methods for your attack’s mode.

Source

src/ai-blackteam/attacks/base.py