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 preflight

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

Overview

Concrete tool for checking that every model a campaign uses is reachable before any attack starts, provided by the HackAgent orchestrator.

Description

The preflight module checks every model a campaign depends on — target, guardrails, attack roles and embedders, judges, and goal classifier — before a single goal is attacked. Building a model validates its configuration but sends nothing, so a wrong endpoint or down server only shows up on the first real call, after the run has started and partly recorded. Preflight checks each distinct model once (deduplicating models used in multiple roles), runs all checks concurrently, and reports every failure together in a single PreflightError.

model_probes builds the probes from what resolution built, mapping id(config) to built models and embedders so a model used in several places is checked once. Each Probe carries a name, the places it is used, an async check callable, and a timeout.

Usage

Import this module when you need to validate model reachability before running a campaign. Preflight is enabled by default (execution.preflight: true) and runs automatically within arun_campaign. Call preflight directly only for standalone validation of a resolved campaign.

Code Reference

Source Location

Signature

async def preflight(resolved: ResolvedCampaign) -> None:
    """Check every model; raise PreflightError naming each failure."""

def model_probes(
    spec: CampaignSpec,
    models: Mapping[int, Model],
    embedders: Mapping[int, Any],
) -> tuple[Probe, ...]:
    """One probe per distinct model, from what resolution built."""

class PreflightError(RuntimeError):
    """One or more of a campaign's models could not be reached."""
    def __init__(self, failures: list[str]) -> None: ...

@dataclass(frozen=True)
class Probe:
    name: str
    uses: tuple[str, ...]
    check: Callable[[], Awaitable[Reachability]]
    timeout: float

Import

from hackagent.orchestrator.campaign.preflight import preflight, model_probes, PreflightError, Probe

I/O Contract

Inputs

Name Type Required Description
resolved ResolvedCampaign Yes Must have .probes populated (one Probe per distinct model)

Outputs

Name Type Description
return None None on success; raises PreflightError if any model is unreachable
PreflightError Carries .failures: list[str] naming each unreachable model

Usage Examples

Run Preflight on a Resolved Campaign

import asyncio
from hackagent.orchestrator.campaign.loader import load_campaign
from hackagent.orchestrator.campaign.resolve import resolve_campaign
from hackagent.orchestrator.campaign.preflight import preflight, PreflightError

spec = load_campaign("campaigns/quick_check.yaml")
resolved = resolve_campaign(spec)

try:
    asyncio.run(preflight(resolved))
    print("All models reachable")
except PreflightError as exc:
    print(f"Preflight failed: {exc}")
    for failure in exc.failures:
        print(f"  - {failure}")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment