Implementation:AISecurityLab Hackagent Attempt
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Data_Models |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for representing one request sent for one goal, the target's reply, and its verdict, provided by the HackAgent orchestrator.
Description
Attempt is a frozen dataclass that holds the complete record of one attack attempt:
- goal_index and request_index: position in the run.
- goal: the attack goal text.
- messages: the chat messages sent to the target.
- response: the target's ModelResponse (text, error, guardrail, latency, metadata).
- decoded: the decoded plain text (after attack.decode), which is what judges see.
- verdict: the panel's Verdict (success, score, votes, explanation, error).
- error: set when the attempt produced nothing to judge (generation failed, target error, guardrail block, decoding failure).
- metadata: attack-specific data (step, technique).
- trace: the search trace nodes for this attempt (iterative attacks).
- labels: the goal's taxonomy labels (category, subcategory), if any.
For iterative attacks, one Attempt is produced per judged exchange, with request_index counting them in order. trace covers the whole search and is carried by the first attempt of a goal.
The companion dataclasses are:
- AttackOutcome: every attempt of one attack, or the error that stopped it.
- CampaignResult: the full run result — campaign name, run ID, attacks, audit, output files.
Usage
- Assembled by the runner:: _AttackRunner._run_request (static) and _attempt_for (iterative) build Attempt objects.
- Consumed by tracking: RunTracker.record persists each attempt to the store.
- Consumed by output: write_outputs serializes attempts to results.json/results.jsonl.
Code Reference
Source Location
- Repository: AISecurityLab_Hackagent
- File: hackagent/orchestrator/campaign/results.py
Signature
@dataclass(frozen=True)
class Attempt:
goal_index: int
request_index: int
goal: str
messages: tuple[Mapping[str, Any], ...] = ()
response: Optional[ModelResponse] = None
decoded: str = ""
verdict: Optional[Verdict] = None
error: Optional[str] = None
metadata: Mapping[str, Any] = field(default_factory=dict)
trace: tuple[TraceNode, ...] = ()
labels: Mapping[str, str] = field(default_factory=dict)
@property
def prompt(self) -> str: """Text of the last user message."""
@property
def errors(self) -> tuple[str, ...]: """Every problem the attempt hit."""
@dataclass(frozen=True)
class AttackOutcome:
name: str
run_id: Optional[str] = None
attempts: tuple[Attempt, ...] = ()
error: Optional[str] = None
run_trace: tuple[TraceNode, ...] = ()
@dataclass(frozen=True)
class CampaignResult:
campaign_name: str
run_id: str
dry_run: bool
campaign_run_id: Optional[str] = None
attacks: tuple[AttackOutcome, ...] = field(default_factory=tuple)
audit: Optional[AuditReport] = None
outputs: tuple[Path, ...] = field(default_factory=tuple)
Import
from hackagent.orchestrator.campaign.results import Attempt, AttackOutcome, CampaignResult
I/O Contract
Outputs
| Name | Type | Description |
|---|---|---|
| Attempt | frozen dataclass | One request/reply/verdict triple for one goal |
| AttackOutcome | frozen dataclass | All attempts of one attack, or its error |
| CampaignResult | frozen dataclass | Full run result with audit and output paths |
Usage Examples
Building and Inspecting Attempts
from hackagent.orchestrator.campaign.results import Attempt, user_text
# Assembled by the runner after generate → complete → decode → judge
attempt = Attempt(
goal_index=0,
request_index=0,
goal="harmful goal text",
messages=({"role": "user", "content": "the prompt"},),
response=model_response,
decoded="the decoded reply",
verdict=verdict,
)
# The prompt property extracts the last user message text
print(f"Prompt: {attempt.prompt}")
# The errors property collects all problems
for err in attempt.errors:
print(f"Error: {err}")
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment