Skip to main content

BreachGuard

BreachGuard generates tailored prompt-injection test cases, executes them through a user-supplied agent runner, intercepts and evaluates tool calls against policies, and exports reproducible failures. It is a typed Python library and CLI (v0.1.0) for AI-agent security testing: you declare tools and policies, seed or LLM-generate attacks with your own provider key, run isolated sessions that never execute intercepted tools by default, and get terminal/JSON/HTML reports plus pytest regressions with CI-friendly exit codes.

Features

Typed definitions for tools, policies, fixtures, and runners

Declare what the agent under test may do with ToolSchema / define_tool, Policy / define_policy / deny_tool / deny_argument_substring / deny_sequence, and define_fixture / FixtureBundle. Plug in any agent via the AgentRunner protocol (run(prompt, tools) -> str) or adapters (CallableRunner, DictMessageRunner, AttributeAgentRunner, OpenAIToolsRunner, ScriptedRunner). Main actions: build schemas in Python, or write a fixture JSON and validate it with breachguard validate-fixture.

Seeded and LLM-backed attack generation

AttackGenerator produces direct, indirect, obfuscated, and multi-step cases (INJECTION_KINDS) from your tools and policy. Seeded generation is offline and deterministic; LLM generation uses your OpenAI-compatible API key via AttackGenerator.with_llm / AttackGenerationConfig (CLI: breachguard generate --llm --api-key …). Hand-authored cases use hand_authored_case or CaseSet.add_hand_authored. Main actions: breachguard init-fixtures, then breachguard generate --fixture … --output ….

Tool-call interception and policy evaluation

Interceptor records every tool invocation before execution, evaluates names (fnmatch), arguments (forbidden keys/substrings), and call sequences (evaluate_call / evaluate_sequence / evaluate_policy), and blocks by default (execute_tools=False). Deny-action hits prevent real side effects unless you explicitly opt in. Main actions: run a TestSession, or call interceptor.intercept(name, args) / bind_schemas from the library.

Isolated, repeatable test sessions

TestSession + SessionOptions filter by case id, tag, or kind; give each case a fresh interceptor; support fixed session_id for comparable reruns; and accept rerun(..., runner=…, prompt_overrides=…) when prompts or agent config change. CaseSet merges seeded and hand-authored cases and applies filters/overrides. Main actions: session.run(cases) in Python, or breachguard run --fixture … --case-id … --tag ….

Reports (terminal, JSON, HTML) with reproduction details

write_report / render_terminal / render_json / render_html include attack inputs, observed tool calls, violated policies, and reproduction hints (reproduction_commands). Brand colours (#003C30 / #00BFAE) appear in HTML. CLI: breachguard run --format terminal|json|html [--output path].

Pytest export and CI exit codes

findings_to_pytest / write_pytest_export turn violations into a parametrized pytest module that replays scripted tool calls. ci_exit_code(report) / SessionReport.exit_code return 0 when clean and 1 on violations or agent failures. CLI: breachguard run … --export-pytest path (process exit code matches the report).

Local fixtures/reports and redaction

Fixtures and reports stay on disk by default (save_fixture / load_fixture / save_report / load_report, under fixtures/ and reports/ via local_fixture_path / local_report_path). load_report accepts both pydantic session dumps and CLI write_report(..., fmt="json") output. RedactionOptions / redact_report / redact_text / redact_mapping strip secrets before writing or sharing. CLI: breachguard run --redact.

Demo agent for local runs without a live LLM

VulnerableDemoRunner follows tool-use hints in prompts so CLI run can demonstrate interception without wiring a real agent. Production users supply their own AgentRunner.

Pages

BreachGuard has no web frontend and no browser routes. It is a Python package and CLI.

Brand assets shipped with the repo (not a UI):

Path What it is
frontend/public/logo.svg Product logo (primary #003C30, accent #00BFAE)
frontend/public/favicon.svg Favicon variant of the logo

API

BreachGuard has no HTTP backend. The public surface is the typed Python package (import breachguard) and the breachguard console script.

CLI commands

Command Purpose
breachguard version Print package version and configured PYPI_PACKAGE_NAME
breachguard init-fixtures [--path] [--force] Write a local demo fixture (tools, policy, hand-authored case)
breachguard validate-fixture --fixture PATH Validate fixture JSON structure
breachguard generate --fixture PATH --output PATH Seeded or LLM-backed case generation (--llm, --api-key, --model, --base-url, --temperature, --seed, --limit, --per-kind, --kind)
breachguard run --fixture PATH Run cases with interception; report formats; optional pytest export (--format, --output, --export-pytest, --redact, --tag, --case-id, --kind, --session-id, --execute-tools)

Also: python -m breachguard (same entrypoint).

Python API (grouped by feature)

Definitions: define_tool, define_policy, define_fixture, deny_tool, deny_argument_substring, deny_sequence, ToolSchema, ToolParameter, Policy, PolicyRule, PolicyAction, FixtureBundle

Generation: AttackGenerator, AttackGenerationConfig, AttackCase, AttackKind, INJECTION_KINDS, hand_authored_case, CaseSet, LLMClient, LLMConfig, LLMError

Runners: AgentRunner, CallableRunner, DictMessageRunner, AttributeAgentRunner, OpenAIToolsRunner, ScriptedRunner, VulnerableDemoRunner, as_runner, bind_schemas, coerce_agent_output

Interception & policy: Interceptor, InterceptResult, ToolCall, PolicyViolation, evaluate_call, evaluate_sequence, evaluate_policy, is_blocking, rule_by_id

Sessions: TestSession, SessionOptions, SessionReport, CaseResult, filter_cases

Reports: ReportFormat, write_report, render_terminal, render_json, render_html, reproduction_commands

Export & CI: findings_to_pytest, write_pytest_export, PytestExportOptions, ci_exit_code

Local storage & redaction: save_fixture, load_fixture, save_report, load_report, local_fixture_path, local_report_path, default_demo_fixture, DEFAULT_FIXTURE_DIR, DEFAULT_REPORT_DIR, RedactionOptions, redact_report, redact_text, redact_mapping

Minimal library usage:

from breachguard import (
    AttackGenerator,
    Policy,
    PolicyRule,
    ScriptedRunner,
    TestSession,
    ToolSchema,
    write_report,
)

tools = [ToolSchema(name="send_email")]
policy = Policy(name="p", rules=[PolicyRule(id="deny-email", tool_name="send_email")])
cases = AttackGenerator(tools, policy, seed=1).generate(limit=3)
report = TestSession(
    tools=tools,
    policy=policy,
    runner=ScriptedRunner(scripted_calls=[("send_email", {"to": "a@b.c", "body": "x"})]),
).run(cases)
print(write_report(report, fmt="terminal"))
raise SystemExit(report.exit_code)

Configuration

Name Required Purpose
PYPI_PACKAGE_NAME Yes (for sessions/reports that call load_settings) Provisioned PyPI distribution name, read at runtime for report metadata and breachguard version

Names only are listed in .env.example. Do not commit a .env file or hardcode values.

Third-party credentials (caller-supplied)

Credential Feature Where to get it
OpenAI-compatible API key LLM-backed attack generation (AttackGenerator.with_llm, CLI generate --llm --api-key) Your LLM provider (e.g. OpenAI API keys dashboard, or any compatible host via --base-url)

BreachGuard never bundles or stores a provider key. Pass it per call / CLI invocation. Optional LLM settings: --model, --base-url, --temperature.

Run it locally

# Install
uv sync

# Optional: package name used in reports / version output
export PYPI_PACKAGE_NAME=breachguard

# Smoke the CLI
uv run breachguard init-fixtures --path fixtures/demo.json --force
uv run breachguard generate --fixture fixtures/demo.json --output fixtures/cases.json --limit 4
uv run breachguard run --fixture fixtures/cases.json --format terminal

# Tests
uv run pytest

# Lint / typecheck / build (wheel + sdist under dist/)
uv run ruff check .
uv run mypy src
uv build

Architecture

Stack: Python package only — no web frontend framework, no HTTP API server, no database, no vector database. Runtime dependencies: Pydantic, Typer, Rich, httpx. Tooling: uv, ruff, mypy, pytest. Distribution name on PyPI: breachguard (import package breachguard).

Repository layout

Path Role
src/breachguard/ Library + CLI (cli.py, models, generator, interceptor, session, reporters, export, …)
src/breachguard/reporters/ Terminal / JSON / HTML report renderers
tests/ Unit tests and doctest runner
frontend/public/ Brand SVG logo and favicon only
pyproject.toml Package metadata, scripts, ruff/mypy/pytest config
.env.example Environment variable names
AGENTS.md Factory product contract (kept as generated)

How “frontend” and “backend” talk: they do not. There is no browser app and no /api server. Users import breachguard from Python or invoke the breachguard CLI; optional LLM calls go outbound over HTTPS to the caller’s configured OpenAI-compatible endpoint using the caller’s key.

Metadata

Release files for breachguard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for breachguard 0.1.0
File Size Uploaded Provenance Actions
breachguard-0.1.0.tar.gz 38.9 kB Without provenance Details for breachguard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for breachguard 0.1.0
File Interpreter ABI Platform Actions
breachguard-0.1.0-py3-none-any.whl Python 3 none any Details for breachguard-0.1.0-py3-none-any.whl

Total release size: 88.0 kB

Release files / breachguard-0.1.0.tar.gz

Download URL breachguard-0.1.0.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e9517f590de064767f64c80f6391f1f4c8b3c41f35d3776468c7006f8f3055ad
BLAKE2b-256 checksum
How to use checksums
7525164958bb3f1be5a6761323c4f92c14198c227674e4bd4a373cc5ef1f97fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / breachguard-0.1.0-py3-none-any.whl

Download URL breachguard-0.1.0-py3-none-any.whl
Size 49.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9e2e9084964fa486fedd75651799bb95a98e6a2ece1d9d09e721e2f1a916ba7
BLAKE2b-256 checksum
How to use checksums
49c7b57dd4a6dfec15d480bdb7aa3fb25a62fc212e5e765d93835b9a0c38a7a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for breachguard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page