Principle:AISecurityLab Hackagent Run Persistence
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Persistence, Reporting |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
A persistence pattern that records every attempt of a campaign run — request, response, verdict, trace, and evaluation — to a store (local SQLite or remote HTTP) and writes reproducible output files to disk.
Description
A red-team campaign produces structured evidence: which goals were attacked, what was sent, what came back, and whether the judges called it a jailbreak. Run persistence captures this in two forms:
Store records (via RunTracker):
- An attack row and a run row when the attack starts (run status: RUNNING).
- A result row per attempt, as soon as it is judged, with evaluation status (SUCCESSFUL_JAILBREAK, FAILED_JAILBREAK, ERROR_TEST_FRAMEWORK), evaluation metrics, response text, latency, and error.
- Trace rows per attempt's search steps (when save_traces is on).
- Final run status (COMPLETED, FAILED, CANCELLED) and run notes.
Output files (via write_outputs):
- campaign.yaml: The campaign that ran, credentials redacted, for reproducibility.
- results.json / results.jsonl: One row per attempt with goal, prompt, response, decoded text, evaluation, error.
- traces.jsonl: Search traces of iterative attacks, one line per attempt, with each node's path for tree rebuilding.
- audit.json: The judge audit report, when one ran.
The store supports two backends: local (SQLite file on this machine) and remote (HackAgent server, authenticated via environment variable). A caller-supplied store stays owned by the caller; one opened by the runner is closed before returning.
Usage
Use this principle when a security testing pipeline must produce auditable, reproducible evidence. Every attempt should be persisted as soon as it is judged, not batched at the end, so a crash leaves partial records rather than none.
Theoretical Basis
# Abstract algorithm (NOT real implementation)
def record(self, attempt):
# Create result row immediately after judging
record = store.create_result(run_id, attempt.goal, attempt.goal_index, ...)
# Write trace rows
for node in attempt.trace:
store.create_trace(record.id, sequence, node.type, node.payload)
# Update with evaluation
store.update_result(record.id,
evaluation_status=_evaluation_status(attempt),
evaluation_metrics=eval_columns(attempt.verdict))
Related Pages
Implemented By
- Implementation:AISecurityLab_Hackagent_RunTracker_record
- Implementation:AISecurityLab_Hackagent_Attempt
- Implementation:AISecurityLab_Hackagent_write_outputs
- Implementation:AISecurityLab_Hackagent_Buckets
- Implementation:AISecurityLab_Hackagent_Storage_Records
- Implementation:AISecurityLab_Hackagent_Store_Protocol
- Implementation:AISecurityLab_Hackagent_Tracking_Evaluation
- Implementation:AISecurityLab_Hackagent_JSON_Serialize
- Implementation:AISecurityLab_Hackagent_HTTP_Client
- Implementation:AISecurityLab_Hackagent_HTTP_API_Models
- Implementation:AISecurityLab_Hackagent_Agent_Create
- Implementation:AISecurityLab_Hackagent_Agent_Update
- Implementation:AISecurityLab_Hackagent_Agent_Partial_Update
- Implementation:AISecurityLab_Hackagent_Generate_Script