Real-time monitoring, alerting, and emergency kill switch for AI agents.
Project description
Bulwark — AI Safety Monitor & Kill Switch
Real-time monitoring, alerting, and emergency kill switch for AI agents.
import bulwark
bulwark.init(api_key="bwk_...", agent_name="my-agent")
with bulwark.session("task-name") as s:
s.track_tool_call("search_web", input={"q": "hello"})
s.track_llm_call("gpt-4", input_tokens=100, cost_usd=0.01)
if s.is_killed():
break # Remote kill switch triggered
Features
- Event tracking — tool calls, LLM calls, actions with full payload capture
- Kill switch — remotely terminate any agent session in real-time
- Alert rules — auto-kill agents that breach thresholds (cost, tool calls, duration)
- LangChain integration — auto-instrument with zero code changes
- Never crashes your agent — degraded mode, retries, fail-open kill switch
Install
pip install bulwark-ai
With LangChain support:
pip install bulwark-ai[langchain]
Quick Start
import bulwark
# Initialize
bulwark.init(
api_key="bwk_...",
agent_name="research-agent",
endpoint="http://localhost:8000",
)
# Track a session
with bulwark.session("data-analysis") as s:
s.track_tool_call("query_db", input={"sql": "SELECT ..."})
s.track_llm_call("claude-sonnet-4-6", input_tokens=1200, cost_usd=0.005)
s.track_action("send_email", target="user@example.com")
if s.is_killed():
print("Agent killed remotely!")
break
Kill Switch Decorator
@bulwark.killswitch(check_interval=3)
def agent_loop(session):
while True:
session.track_tool_call("work")
time.sleep(1)
with bulwark.session("my-task") as s:
agent_loop(s) # Exits cleanly on kill signal
LangChain Auto-Instrumentation
from bulwark.integrations.langchain import BulwarkCallbackHandler
with bulwark.session("langchain-task") as s:
handler = BulwarkCallbackHandler(session=s)
agent.invoke(input, config={"callbacks": [handler]})
Error Handling
The SDK never crashes your agent:
- Events buffer in memory (up to 1,000) when the API is unreachable
- Automatic retry with exponential backoff on server errors
- Kill switch is fail-open (agent keeps running if API is down)
client = bulwark.get_client()
print(f"Healthy: {client.is_healthy}")
print(f"Buffered: {client.buffer_size}")
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bulwark_ai-0.1.0.tar.gz
(12.3 kB
view details)
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 bulwark_ai-0.1.0.tar.gz.
File metadata
- Download URL: bulwark_ai-0.1.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
365f1d177b82ba90978dcc64c46ce2fa5ade702bdd33597310466617c2d15ddf
|
|
| MD5 |
00a05c3166967878893bcb69b980f912
|
|
| BLAKE2b-256 |
c17b296fd67a3e8296ccb15791466c1ea7bca8532553828f4d4031d04af7ed42
|
File details
Details for the file bulwark_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bulwark_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
908be28762dcb4d8c4174991e60dc9c0d7ed826526af4264a27e52235a709b73
|
|
| MD5 |
b84301ede1f76b026793704c80b40f10
|
|
| BLAKE2b-256 |
082669c8a4675e85bc8d1b62f1e695f3d0a3e80858009ba3604a7ad4c52a0460
|