Skip to main content
The CLI is a thin wrapper around a library. Anything agent-guardian scan can do is reachable from Python. This page documents the public API — the symbols exported by agent_guardian.__all__. Everything else (agent_guardian._*, agent_guardian.core.* internals) is unstable and may change without notice.

When to use this

Reach for the SDK when you need to:
  • Drive a scan from inside an existing Python test suite or workflow.
  • Build adapters that wrap a framework AgentGuardian doesn’t ship out of the box (subclass TargetAdapter).
  • Author a custom probe and feed it to an existing agent slate.
  • Verify a signed report inline without shelling out.
  • Estimate scan cost before kicking one off.
For one-off scans, the CLI is faster. The SDK starts paying off the moment you want programmatic access to Scan, Finding, or AivssResult.

The three wedges

Every scan starts with the same three building blocks. The CLI just calls these for you.
SwarmCommander is single-shot — call .run() exactly once. The Scan it returns is a Pydantic model you can serialise, persist, or feed back into a report writer.

Running with a real provider

Build LLM clients directly and pass them in.
Every provider client follows the same shape. The full list of clients is below.

Adapters

Build a TargetAdapter to teach AgentGuardian how to send a probe to your agent and read its response. All adapters share the TargetAdapter base. Subclass it for anything exotic — the contract is two async methods (fingerprint, send) and a TargetFingerprint payload describing what you discovered about the target during probe.
Use list_shapes() to see every registered shape; register_shape() to add your own.

LLM clients

Every client implements BaseLLM and emits LLMUsage so cost rollups work uniformly.

Stub script

StubScript is the recommended way to drive deterministic tests:
Anything not matched by an explicit .on(pattern, response) falls back to the .default(...) reply.

Probes

Probes are YAML files that ship with the package. Load them from Python:
A Probe carries id, name, asi, severity, tier_floor, prompts, and metadata. load_probe(path) raises ProbeValidationError on a bad schema.

Reports

Write the same five output formats the CLI emits:

Signatures

JSON reports are signed by default. Verify them inline:
The crypto building blocks (sign_ed25519, verify_ed25519, sign_hmac, verify_hmac, Ed25519Keypair, HmacSignatureBlock) are also public if you need to sign / verify outside the report flow.

Cost estimation

PRICE_TABLE_AS_OF is the date stamp on the bundled prices so you know how stale they are.

Scoring

Tier detection

Models you can pass around

The Pydantic models that ride the public surface:

Memory + sandbox

SharedMemory is the swarm’s cross-agent scratchpad. Sandbox is the process-isolation primitive used by code-exec-agent. PiiRedactor runs on every finding before it lands in a report.

Strategies

Adversarial decision policies. Default agents pick one; you can drive your own: All four implement Strategy. Use StrategyContext, Turn, NextPrompt, StrategyDone, and StrategyResult to thread them into a custom agent.

Server

The dashboard backs onto ScanStore. Mount the app behind any ASGI server. The CLI uses uvicorn.

Full export list

The complete set of public symbols (agent_guardian.__all__):
Anything not in this list is internal. If you find yourself reaching into agent_guardian.core.* or any underscore-prefixed module, open an issue — we’d rather lift the symbol into the public surface than have you depend on an internal.

Next step

  • Pair the SDK with the Config precedence rules so programmatic scans see the same defaults as the CLI.
  • Map provider errors to your own retry policy via the Error codes taxonomy.
  • Drive the same surface from the shell with the CLI reference.