pyrit.executor.attack.SingleTurnAttackContext#

class SingleTurnAttackContext(params: AttackParamsT, start_time: float = 0.0, related_conversations: set[ConversationReference] = <factory>, _next_message_override: Optional[Message] = None, _prepended_conversation_override: Optional[List[Message]] = None, _memory_labels_override: Optional[Dict[str, str]] = None, conversation_id: str = <factory>, system_prompt: Optional[str] = None, metadata: Optional[dict[str, Union[str, int]]] = None)[source]#

Bases: AttackContext[AttackParamsT]

Context for single-turn attacks.

Holds execution state for single-turn attacks. The immutable attack parameters (objective, next_message, prepended_conversation, memory_labels) are stored in the params field inherited from AttackContext.

__init__(params: AttackParamsT, start_time: float = 0.0, related_conversations: set[ConversationReference] = <factory>, _next_message_override: Optional[Message] = None, _prepended_conversation_override: Optional[List[Message]] = None, _memory_labels_override: Optional[Dict[str, str]] = None, conversation_id: str = <factory>, system_prompt: Optional[str] = None, metadata: Optional[dict[str, Union[str, int]]] = None) None#

Methods

__init__(params[, start_time, ...])

duplicate()

Create a deep copy of the context.

Attributes

memory_labels

Additional labels that can be applied to the prompts throughout the attack.

metadata

next_message

Optional message to send to the objective target.

objective

Natural-language description of what the attack tries to achieve.

prepended_conversation

Conversation that is automatically prepended to the target model.

start_time

system_prompt

conversation_id

params

related_conversations

conversation_id: str#
metadata: dict[str, str | int] | None = None#
system_prompt: str | None = None#