The CLI is a thin wrapper around a library. AnythingDocumentation Index
Fetch the complete documentation index at: https://docs.agentguardian.io/llms.txt
Use this file to discover all available pages before exploring further.
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.
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.Adapters
Build aTargetAdapter to teach AgentGuardian how to send a probe to
your agent and read its response.
| Class | Wraps |
|---|---|
PromptAdapter | A raw system prompt + an LLM. The adapter roleplays the target. |
CodeAdapter | A Python callable referenced by dotted path (my_app.agent:run). |
HttpAdapter | A hosted HTTP endpoint. Pair with one of the registered HttpShapes. |
LangGraphAdapter | A compiled LangGraph graph. |
CrewAIAdapter | A CrewAI Crew. |
AutoGenAdapter | An AutoGen group chat. |
OpenAIAgentsAdapter | An OpenAI Agents SDK agent. |
StrandsAdapter | A Strands agent. |
ADKAdapter | A Google ADK agent. |
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.
list_shapes() to see every registered shape; register_shape() to
add your own.
LLM clients
| Client | Provider | Auth |
|---|---|---|
OpenAIClient | OpenAI | api_key (env: OPENAI_API_KEY / AGENT_GUARDIAN_OPENAI_API_KEY). |
AnthropicClient | Anthropic | api_key (env: ANTHROPIC_API_KEY / AGENT_GUARDIAN_ANTHROPIC_API_KEY). |
GeminiClient | Google AI Studio | api_key (env: GEMINI_API_KEY / GOOGLE_API_KEY / AGENT_GUARDIAN_GEMINI_API_KEY). |
OllamaClient | Local Ollama | No auth. |
BedrockClient | AWS Bedrock | Standard AWS credential chain. Requires [aws] extra. |
VertexClient | Vertex AI | Request-builder-only today (M9-pending OAuth2 SA auth). |
StubLLM / StubScript | Deterministic test stub | No auth. Use for tests / dry runs. |
BaseLLM and emits LLMUsage so cost rollups
work uniformly.
Stub script
StubScript is the recommended way to drive deterministic tests:
.on(pattern, response) falls back
to the .default(...) reply.
Probes
Probes are YAML files that ship with the package. Load them from Python: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: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:| Model | Carries |
|---|---|
Scan | Full scan result. aivss, findings, tier, cost_usd, signatures. |
Finding | One concrete adversarial finding. ID, ASI, severity, summary, transcript_ref. |
Scenario / ScenarioBatch | Attacker scenarios emitted into / consumed by a strategy. |
Probe | One YAML probe. |
SwarmEvent | Streamed via SwarmObserver callback during a scan. |
JudgeVerdict | One judge ruling on one turn. |
AivssResult | Output of compute_aivss. |
TargetFingerprint | What recon learned about a target. |
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:| Strategy | Family |
|---|---|
PAIRStrategy | PAIR (Prompt Automatic Iterative Refinement). |
TAPStrategy | TAP (Tree of Attacks with Pruning). |
CrescendoStrategy | Multi-turn escalation. |
MadMaxStrategy | Worst-case stress test. |
Strategy. Use StrategyContext, Turn,
NextPrompt, StrategyDone, and StrategyResult to thread them into a
custom agent.
Server
ScanStore. Mount the app behind any ASGI
server. The CLI uses uvicorn.
Full export list
The complete set of public symbols (agent_guardian.__all__):
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.