Implementation:AISecurityLab Hackagent resolve campaign
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Dependency_Injection |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for turning a validated campaign specification into the runtime objects a run needs — goals, model clients, attacks, and judge panel — provided by the HackAgent orchestrator.
Description
resolve_campaign instantiates everything a CampaignSpec describes: it loads goals from the dataset, builds the target model (optionally wrapped in guardrails), constructs the judge panel, and builds each attack from its parameters plus traced completion callables for its role models. No request is sent to any model during resolution — it is purely construction. The function accepts injectable builder callables (build, load, build_embed) so tests and custom integrations can substitute their own model factories.
The module also provides resolve_attack (constructs one attack, binding each role model to the shape it declares), build_panel (binds every judge to its model), and _guarded (wraps the target in before/after guardrail classifiers).
Usage
- Standard campaign resolution: Call resolve_campaign(spec) after loading a campaign to get a ResolvedCampaign ready for preflight and execution.
- Custom model builders: Pass alternative build, load, or build_embed callables to inject mock models in tests.
- Panel-only construction: Call build_panel directly to construct a judge panel without resolving the whole campaign (used by run_audit).
Code Reference
Source Location
- Repository: AISecurityLab_Hackagent
- File: hackagent/orchestrator/campaign/resolve.py
Signature
def resolve_campaign(
spec: CampaignSpec,
*,
build: ModelBuilder = build_model,
load: GoalLoader = load_goals,
build_embed: EmbedderBuilder = build_embedder,
) -> ResolvedCampaign:
"""Instantiate everything spec describes."""
def resolve_attack(
spec: AttackSpec,
build: ModelBuilder,
*,
retries: int = 0,
build_embed: EmbedderBuilder = build_embedder,
) -> ResolvedAttack:
"""Construct an attack, binding each role model to the shape it declares."""
def build_panel(
spec: EvaluationSpec,
build: ModelBuilder,
*,
retries: int = 0,
) -> Optional[Panel]:
"""Bind every judge to its model. None when no judge is configured."""
Import
from hackagent.orchestrator.campaign.resolve import resolve_campaign, resolve_attack, build_panel
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| spec | CampaignSpec | Yes | The validated campaign specification |
| build | ModelBuilder | No | Factory that creates a Model from a ModelConfig (default: build_model) |
| load | GoalLoader | No | Loads goals from a DatasetSpec (default: load_goals) |
| build_embed | EmbedderBuilder | No | Builds embedding callables (default: build_embedder) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | ResolvedCampaign | Dataclass: spec, goals, target, panel, attacks, classifier, probes |
| ResolvedAttack | dataclass | name, attack (StaticAttack or IterativeAttack), configuration dict |
| panel | Optional[Panel] | None when no judges configured |
Usage Examples
Resolve and Inspect
from hackagent.orchestrator.campaign.loader import load_campaign
from hackagent.orchestrator.campaign.resolve import resolve_campaign
spec = load_campaign("campaigns/quick_check.yaml")
resolved = resolve_campaign(spec)
print(f"Goals: {len(resolved.goals)}")
print(f"Attacks: {[a.name for a in resolved.attacks]}")
print(f"Panel: {resolved.panel is not None}")
Resolve with Custom Model Builder
from hackagent.orchestrator.campaign.loader import load_campaign
from hackagent.orchestrator.campaign.resolve import resolve_campaign
# Inject a mock model builder for testing
def mock_build(config, *, retries=0):
return MockModel(config)
resolved = resolve_campaign(spec, build=mock_build)