Skip to main content

agentbouncr

PyPI version Python versions License: MIT

Governance for autonomous AI agents. Every tool call is checked against your policies before execution.

Native adapters for LangChain / LangGraph (drop-in callback) and CrewAI (tool wrapper). Any other framework works via the plain HTTP evaluate() client.

Installation

pip install agentbouncr

For LangChain integration:

pip install "agentbouncr[langchain]"

For CrewAI integration:

pip install "agentbouncr[crewai]"

30-Second Quickstart

from agentbouncr import AgentBouncr

client = AgentBouncr(api_key="sk_live_your_key_here")

result = client.evaluate(
    agent_id="my-research-agent",
    tool="send_email",
    params={"to": "user@example.com"},
)

if result.allowed:
    send_email(to="user@example.com")
else:
    print(f"Blocked by policy: {result.reason}")

LangChain in 3 Lines

from agentbouncr import AgentBouncr
from agentbouncr.langchain import AgentBouncrCallbackHandler

client = AgentBouncr(api_key="sk_live_your_key_here")
handler = AgentBouncrCallbackHandler(client, agent_id="my-research-agent")

executor = AgentExecutor(agent=agent, tools=tools)
executor.invoke({"input": "Find the latest AI news"}, config={"callbacks": [handler]})

Every tool call now passes through AgentBouncr first. Observe-first is the default (enforce=False): denials and unreachable-API errors are logged and execution always proceeds — governance stays off the agent's critical path (not a SPOF). Opt into the fail-closed path with enforce=True:

handler = AgentBouncrCallbackHandler(client, agent_id="my-research-agent", enforce=True)
# enforce=True: a denied call raises GovernanceDeniedError; an unreachable API re-raises.

Important — pass callbacks at invoke time, not in the constructor. In LangChain 0.3.x, passing callbacks=[handler] to AgentExecutor(...) attaches the handler to the executor but does not reliably propagate it to the inner tool runs. The on_tool_start hook then never fires and governance is silently bypassed. Always pass callbacks via the per-call config={"callbacks": [handler]} argument to .invoke() / .stream() / .ainvoke() — this is the supported path and the one we test against.

LangGraph works the same way:

app = create_react_agent(llm, tools)
app.invoke({"messages": [...]}, config={"callbacks": [handler]})

Coverage

The handler intercepts standard LangChain/LangGraph tool runs via on_tool_start. That covers the patterns used by create_react_agent, AgentExecutor with Tool / StructuredTool / BaseTool subclasses, and native function-calling tool wrappers.

It does not intercept code paths that bypass the tool abstraction — for example a raw Runnable chain that calls an external API directly, or a custom node in a LangGraph that invokes an HTTP client without wrapping it as a tool. For those, call client.evaluate(...) yourself before the side effect.

CrewAI in 3 Lines

from agentbouncr import AgentBouncr
from agentbouncr.crewai import govern_tools

client = AgentBouncr(api_key="sk_live_your_key_here")

# Observe-first (default): every tool call is evaluated + logged, execution always proceeds.
agent = Agent(role="researcher", tools=govern_tools(tools, client, "my-research-agent"))

For the fail-closed path, wrap a tool with enforce=True — a denied call then raises GovernanceDeniedError and the wrapped tool never runs:

from agentbouncr.crewai import govern_tool

enforced = govern_tool(my_tool, client, agent_id="my-research-agent", enforce=True)

Both native adapters default to observe-first and share the same enforce flag: denials are advisory (logged, never blocking) and an unreachable API does not block the tool until you opt into enforce=True.

Authentication

Get an API key from your AgentBouncr Dashboard under Settings → API Keys.

client = AgentBouncr(api_key="sk_live_...")

For multi-workspace setups:

client = AgentBouncr(
    api_key="sk_live_...",
    tenant_id="your-workspace-id",
)

Configuration

client = AgentBouncr(
    api_key="sk_live_...",
    base_url="https://agentbouncr.com",  # default
    timeout=5.0,                              # request timeout in seconds
    max_retries=3,                            # exponential backoff for 5xx/429
    tenant_id=None,                           # optional X-Tenant-Id header
)

Error Handling

from agentbouncr import (
    AgentBouncrError,        # base class
    AuthenticationError,     # 401
    ValidationError,         # 400
    RateLimitError,          # 429 after retries exhausted
    ServerError,             # 5xx after retries exhausted
    TimeoutError,            # request exceeded timeout
    GovernanceDeniedError,   # raised by LangChain handler when policy denies
)

Links

License

MIT — see LICENSE.

The AgentBouncr backend is commercial software. The SDK is open source so you can audit, patch, and integrate freely.

Release files for agentbouncr 0.2.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 agentbouncr 0.2.0
File Size Uploaded
agentbouncr-0.2.0.tar.gz 19.8 kB Details

Built distribution (wheel)

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

Total release size: 35.0 kB

Release files / agentbouncr-0.2.0.tar.gz

Download URL agentbouncr-0.2.0.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e9c43c26bffcddf3db34ddb0dad74ed28c82d02c288a24750b5fbec4c281fab1
BLAKE2b-256 checksum
How to use checksums
1069080db030452e047c81971fdd480bdb8859bf1e1478c604a4c3346a4285ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 2, 2026.

Transparency log

Release files / agentbouncr-0.2.0-py3-none-any.whl

Download URL agentbouncr-0.2.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de6cea824863cde218d7f810a14ae176232a110e254272b539d93f10a816ae37
BLAKE2b-256 checksum
How to use checksums
2cdac1864e2d93cedb4b5e288978190b4b7d77b5cd3a9a02c9a5fd1a41cd8df1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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