Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AISecurityLab Hackagent Crescendo Prompts

From Leeroopedia
Knowledge Sources
Domains Security_Testing, Prompt_Engineering
Last Updated 2026-10-29 00:00 GMT

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.
Principle
Implementation
Heuristic
Environment