Skip to main content

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bulwark_ai-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

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

Hashes for bulwark_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 365f1d177b82ba90978dcc64c46ce2fa5ade702bdd33597310466617c2d15ddf
MD5 00a05c3166967878893bcb69b980f912
BLAKE2b-256 c17b296fd67a3e8296ccb15791466c1ea7bca8532553828f4d4031d04af7ed42

See more details on using hashes here.

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

Hashes for bulwark_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 908be28762dcb4d8c4174991e60dc9c0d7ed826526af4264a27e52235a709b73
MD5 b84301ede1f76b026793704c80b40f10
BLAKE2b-256 082669c8a4675e85bc8d1b62f1e695f3d0a3e80858009ba3604a7ad4c52a0460

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page