Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3. Memory Types

There are several types of data you can retrieve from memory at any point in time using the MemoryInterface.

MessagePiece and Message

One of the most fundamental data structures in PyRIT is MessagePiece and Message. These classes provide the foundation for multi-modal interaction tracking throughout the framework.

MessagePiece

MessagePiece represents a single piece of a request to a target. It is the atomic unit that is stored in the database and contains comprehensive metadata about each interaction.

Key Fields:

This rich context allows PyRIT to track the full lifecycle of each interaction, including transformations, targeting, scoring, and error handling.

Message

Message represents a single request or response to a target and can contain multiple MessagePieces. This allows for multi-modal interactions where, for example, you send both text and an image in a single request.

Examples:

Validation Rules:

Conversation Structure

A conversation is a list of Messages that share the same conversation_id. The sequence of the MessagePieces and their corresponding Messages dictates the order of the conversation.

Here is a sample conversation made up of three Messages which all share the same conversation ID. The first Message is the system message, followed by a multi-modal user prompt with a text MessagePiece and an image MessagePiece, and finally the assistant response in the form of a text MessagePiece.

This architecture is plumbed throughout PyRIT, providing flexibility to interact with various modalities seamlessly. All pieces are stored in the database as individual MessagePieces and are reassembled when needed. The PromptNormalizer automatically adds these to the database as prompts are sent.

SeedPrompts

SeedPrompt objects represent the starting points of conversations. They are used to assemble and initiate attacks, and can be translated to and from MessagePieces.

Key Fields:

SeedPrompts support Jinja2 templating, allowing dynamic prompt generation with parameter substitution. They can be loaded from YAML files and organized into datasets and groups for systematic testing.

SeedObjectives

SeedObjective objects represent the goal or objective of an attack or test scenario. They describe what the attacker is trying to achieve and are used alongside SeedPrompts to define complete attack scenarios.

Key Fields:

SeedObjectives support Jinja2 templating for dynamic objective generation and can be loaded from YAML files alongside prompts, making it easy to organize and reuse test objectives across different scenarios.

Relationship to SeedGroups:

SeedObjective and SeedPrompt objects are combined into SeedGroup objects, which represent a complete test case with optional seed prompts and an objective. A SeedGroup can contain:

Scores

Score objects represent evaluations of prompts or responses. Scores are generated by scorer components and attached to MessagePieces to track the success or characteristics of attacks. When a prompt is scored, it is added to the database and can be queried later.

Key Fields:

Scores enable automated evaluation of attack success, content harmfulness, and other metrics throughout PyRIT’s red teaming workflows.

AttackResults

AttackResult objects encapsulate the complete outcome of an attack execution, including metrics, evidence, and success determination. When an attack is run, the AttackResult is added to the database and can be queried later.

Key Fields:

AttackResult objects provide comprehensive reporting on attack campaigns, enabling analysis of red teaming effectiveness and vulnerability identification.