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.

Seeds

All seed types inherit from Seed, which provides common fields (value, value_sha256, dataset_name, harm_categories, is_general_technique, metadata, etc.) along with Jinja2 templating and YAML loading support.

Seed Types

Seed Groups

Seeds are organized into SeedGroup containers that enforce consistency (shared prompt_group_id, valid role sequences, no duplicate sequence numbers). Two specialized subclasses add further constraints:

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.

ComponentIdentifiers

ComponentIdentifier is an immutable snapshot of a component’s behavioral configuration. A single type is used for all components — targets, scorers, converters, and attacks — enabling uniform storage and composition.

Key Fields:

Identifiers are content-addressed: the same configuration always produces the same hash, and any change to params or children produces a different one. This is used throughout PyRIT to track which exact configuration produced a given result.

Composite Identifiers

For atomic attacks, build_atomic_attack_identifier composes a tree of identifiers:

Eval Hashing

EvaluationIdentifier subclasses wrap a ComponentIdentifier and compute a separate eval hash that strips operational params (like endpoint URLs) so the same logical configuration on different deployments produces the same hash. This enables grouping equivalent runs for evaluation comparison.