Agentic Risk Infrastructure. Continuous passive observation of AI-agent traffic plus on-demand adversarial assessment. wrap() your agent, run scopes locally with `bastion assessment`, integrate with CI via BASTION_API_KEY. Covers OWASP LLM Top 10.
Project description
bastion-red
Adversarial assessment SDK for AI agents. Python equivalent of @pistonsolutions/bastion. Same CLI, same wrap() programmatic API, same scope authoring, same hosted-runner endpoints.
pipx install bastion-red # or: uv tool install bastion-red
bastion login
bastion run --target https://your-agent.example.com/chat --plugin pii-direct
The same run appears in your dashboard with the full probe ↔ target transcript.
Full reference: https://bastion.pistonsolutions.ai/docs
Quickstart
pipx install bastion-red
bastion login # opens dashboard, hands API key back to terminal
bastion init # scaffold .bastion/ in the current repo
bastion run --scope SCOPE.md # text assessment
# or:
bastion voice --target-ws wss://your-agent.example.com/voice \
--rule "Do not disclose PII without verification"
Requires Python ≥ 3.10.
Architecture
The SDK is a thin client. Your machine never runs an LLM, opens a WebSocket to your target, or places a phone call — all of that happens on Bastion infra. The CLI reads your scope, POSTs a job descriptor with your bk_* token, polls until the run completes.
What this means: only your target's URL/DID and the scope leave your network. No LLM keys on your end, no telephony provider to integrate, no WebRTC stack to install.
Failsafe: if the primary probe engine fails on a given run, Bastion falls back to a curated payload catalog automatically. You get telemetry from every bastion run, not an empty report.
Modes
| Mode | Command | When to use |
|---|---|---|
| Text | bastion run --target <url> |
HTTP chat endpoints, RAG, agent backends |
| Voice WebSocket | bastion voice --target-ws <wss> |
In-house voice agents you can expose as 8 kHz μ-law WS |
| Telephony | bastion voice --target-did <e164> |
Agents on a phone number; tests real PSTN conditions |
bastion run --target https://your-agent.example.com/chat --plugin pii-direct
bastion voice --target-ws wss://your-agent.example.com/voice --rule "..."
bastion voice --target-did +14155551234 --rule "..."
Telephony note: only test phone numbers you own or have explicit written authorization to test.
Programmatic API: wrap()
from bastion import wrap
def agent(msg: str) -> str:
return llm.complete(msg)
traced = wrap(agent, mode="observe", on_event=lambda e: print("event", e["session_id"]))
traced("hello")
Events flow into the dashboard's Live Activity view. Flagged events auto-promote into scope-seeds so the next assessment can replay them as adversarial probes.
SCOPE.md
YAML frontmatter + markdown body. Frontmatter declares what to test; body describes the agent for grading context.
---
target: https://api.example.com/v1/chat/completions
model: gpt-4o-mini
headers:
Authorization: Bearer ${OPENAI_API_KEY}
categories:
- system_prompt_extraction
- pii_leakage
- jailbreak_resistance
---
# Customer-support agent
The agent answers billing questions for retail customers. Must verify identity
(email + last 4 of card) before discussing any account, must refuse refunds
above $100 without supervisor approval.
Env vars in headers interpolate via ${VAR}. Categories default to system_prompt_extraction if omitted.
CLI reference
| Command | What it does |
|---|---|
bastion login |
Authenticate; persists ~/.bastion/credentials.json |
bastion whoami |
Print email, org, credential source |
bastion init [--ci] |
Scaffold .bastion/ in the current repo |
bastion run |
Text assessment (thin-client by default) |
bastion voice --target-ws <url> |
Voice WebSocket probe |
bastion voice --target-did <e164> |
Telephony probe |
bastion assessment |
Run the configured scope |
bastion diff [a] [b] |
Compare two reports |
bastion docs |
Open the docs page |
Every command supports --help.
Authentication
Two ways to provision a bk_* key:
- Interactive:
bastion login(opens browser, hands key back, persists~/.bastion/credentials.jsonmode 0600) - CI:
export BASTION_API_KEY=bk_live_...
Resolution order: env → file. Keys revocable from the dashboard.
CI/CD
name: Bastion Assessment
on: { pull_request: {}, push: { branches: [main] } }
jobs:
bastion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.12' }
- run: pipx install bastion-red
- run: bastion run --scope SCOPE.md --no-tui
env: { BASTION_API_KEY: ${{ secrets.BASTION_API_KEY }} }
Privacy
- Only the scope you write leaves your machine.
- Verbatim target responses are stored as evidence — if your agent returns real PII, that PII is visible in the dashboard transcript.
- API keys never leave the dashboard in plaintext (only a SHA-256 hash).
- Runs are scoped to the org that minted the API key.
MIT © Piston Solutions
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bastion_red-0.4.14.tar.gz.
File metadata
- Download URL: bastion_red-0.4.14.tar.gz
- Upload date:
- Size: 40.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36df4c29d0cc0960728e741d77f251ff04beb3e5ff87f6ed4fe98329be88006d
|
|
| MD5 |
f7b2ab8ded499729c16c35e34c1e3b30
|
|
| BLAKE2b-256 |
ab49a31be0847ce8cf7c01422e15ac6d4f9246403dd67f23c69d5c712c495321
|
File details
Details for the file bastion_red-0.4.14-py3-none-any.whl.
File metadata
- Download URL: bastion_red-0.4.14-py3-none-any.whl
- Upload date:
- Size: 45.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
149b7b2f18d7639172d418410bbc035be254bcbd4f85522c83add514fc3f0ad4
|
|
| MD5 |
37511ba6f3a5f6c9b670b1c76d3cd84c
|
|
| BLAKE2b-256 |
870e0a992978d87159610281c9041fc44d671374fcc07395152e005be8ae6b62
|