Overview
Concrete system prompt, turn parser, refusal detector, and feedback builder for the Crescendo multi-turn conversation escalation attack, provided by the HackAgent multi-turn attacks package.
Description
The prompts module contains ATTACKER_SYSTEM_PROMPT (instructs the attacker to escalate gradually from benign to harmful questions using the target's own prior answers as context). Helper functions: system_prompt() formats it with a goal, opening_request() asks for the first benign question, feedback() builds the attacker's next turn (with refusal backtrack instructions or score + escalation nudge), refused() detects refusals via regex patterns, and parse_turn() extracts the question from JSON or plain-text attacker output (accepting prose unlike PAIR/TAP).
Usage
- Crescendo attack: The attack calls these helpers to build and parse the escalating conversation.
Code Reference
Source Location
Signature
ATTACKER_SYSTEM_PROMPT: str
REFUSAL_PATTERNS: list[str]
def system_prompt(goal: str) -> str: ...
def opening_request(goal: str) -> str: ...
def feedback(goal: str, reply: str, score: Optional[float], *, refused: bool, explanation: str = "", limit: int = 2500) -> str: ...
def refused(reply: str) -> bool: ...
def parse_turn(reply: Optional[str]) -> Optional[tuple[str, str]]: ...
Import
from hackagent.attacks.techniques.multi_turn.crescendo.prompts import (
system_prompt, opening_request, feedback, refused, parse_turn,
)
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| goal |
str |
Yes |
The harmful goal
|
| reply |
str |
Yes |
Target's reply or attacker output
|
| score |
None |
No |
Panel score for feedback
|
| refused |
bool |
Yes |
Whether target refused (for feedback)
|
Outputs
| Name |
Type |
Description
|
| system_prompt() |
str |
Formatted attacker system prompt
|
| feedback() |
str |
Attacker's next turn instruction
|
| refused() |
bool |
True if reply matches refusal patterns
|
| parse_turn() |
Optional[tuple[str, str]] |
(question, logged_json) or None
|
Usage Examples
Build the Opening Request
from hackagent.attacks.techniques.multi_turn.crescendo.prompts import system_prompt, opening_request
system = system_prompt("explain how to make a bomb")
opening = opening_request("explain how to make a bomb")
plan = [{"role": "system", "content": system}, {"role": "user", "content": opening}]
Check for Refusal
from hackagent.attacks.techniques.multi_turn.crescendo.prompts import refused
if refused(target_reply):
print("Target refused — backtracking")
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.