Skip to main content

AgentBarrier icon

AgentBarrier

Prove your AI agent cannot act after rejection, cancellation, timeout, or replay.

PyPI version Python versions CI status License

AgentBarrier is a deterministic test harness for the control guarantees around AI-agent tool execution. It verifies that approval, rejection, cancellation, timeout, replay, delegation, ambiguous outcomes, audit receipts, and parallel execution controls prevent unintended side effects.

It does not judge model responses and does not need an API key. AgentBarrier invokes controlled sentinel tools, observes their effects outside the agent framework, and reports whether the framework or application honored the expected lifecycle boundary.

Status: early development. The public adapter contract is usable, but compatibility should be pinned until the first stable release.

Adapter guide · Compatibility · CI guide · Payment example · Threat model · Roadmap · Contributing

See a real control failure

The first run below uses an intentionally unsafe adapter that commits while approval is still pending. AgentBarrier catches the real sentinel effect as AB002. The second run exercises the safe reference adapter and passes the same guarantee.

AgentBarrier detects an effect committed before approval, then passes the safe reference adapter

The failure is produced by a real sentinel commit. View the reproducible recording source.

Why

An agent that can send a message, issue a refund, modify a database, or deploy code needs stronger evidence than a configuration flag named requires_approval. AgentBarrier tests the behavior at the effect boundary:

  • no effect before approval;
  • no effect after rejection;
  • approval is bound to the exact reviewed arguments;
  • replay does not execute the same action twice;
  • a lost post-commit response is reported as unknown and reconciled before retry;
  • cancelled and timed-out work cannot commit later;
  • a pending approval can hold sibling effects under the strict run-barrier profile;
  • delegated work inherits its parent's rejection; and
  • approval decisions produce action-digest-bound receipts.

Quick start

python -m pip install agentbarrier
agentbarrier self-test

The self-test runs every guarantee against AgentBarrier's safe reference adapter. Application and framework adapters implement the small AgentAdapter / RunHandle contract.

Use AgentBarrier in CI when your agent can cross a consequential boundary such as sending a message, issuing a refund, changing a database, deploying code, or invoking another agent.

from agentbarrier import SuiteRunner
from myapp.agentbarrier_adapter import MyApplicationAdapter

result = SuiteRunner().verify_sync(MyApplicationAdapter())
result.raise_for_failure()

SQLite database boundary example

The repository includes a credential-free SQLite payment-ledger example with intentionally unsafe and safe adapters. It verifies real local balance and transaction state across approval, rejection, replay, response loss, cancellation, and timeout—without presenting the example as production payment code.

uv run python -m examples.run_payment_ledger

Approval-barrier profiles

The default run-wide profile requires any pending approval to hold every sibling effect in the logical run. Select per-action when the intended contract allows ungated siblings to continue but still requires the gated action itself to remain effect-free until approval.

from agentbarrier import ApprovalBarrierProfile, RunnerOptions, SuiteRunner

runner = SuiteRunner(RunnerOptions(approval_profile=ApprovalBarrierProfile.PER_ACTION))
result = runner.verify_sync(MyApplicationAdapter())
result.raise_for_failure()

The equivalent CLI option is --approval-profile per-action. A stricter run-wide adapter also passes the per-action profile; the profile chooses the minimum contract being tested, not how an adapter must schedule its work.

Framework probes

The built-in probes use deterministic local plans. They do not call a model provider or require an API key.

python -m pip install 'agentbarrier[openai]'
agentbarrier verify agentbarrier.adapters.openai_agents:OpenAIAgentsAdapter

python -m pip install 'agentbarrier[langgraph]'
agentbarrier verify agentbarrier.adapters.langgraph:LangGraphAdapter

python -m pip install 'agentbarrier[pydantic-ai]'
agentbarrier verify agentbarrier.adapters.pydantic_ai:PydanticAIAdapter

python -m pip install 'agentbarrier[google-adk]'
agentbarrier verify agentbarrier.adapters.google_adk:GoogleADKAdapter

python -m pip install 'agentbarrier[autogen]'
agentbarrier verify agentbarrier.adapters.autogen:AutoGenAdapter

python -m pip install 'agentbarrier[crewai]'
agentbarrier verify agentbarrier.adapters.crewai:CrewAIAdapter \
  --approval-profile per-action

The core, OpenAI, PydanticAI, Google ADK, AutoGen, and CrewAI adapters support Python 3.10–3.13. The LangGraph adapter requires Python 3.11+ because its interrupt lifecycle relies on async runnable-context propagation. Google ADK currently marks its tool-confirmation feature as experimental, so its adapter may emit that upstream warning during verification.

CrewAI is installed and tested separately from the all extra because its current OpenAI SDK 2.x requirement conflicts with OpenAI Agents' 3.x requirement. Its real pre-tool hook enforces per-action approval, rejection, and argument binding; CrewAI's threaded tools do not provide a safe cancellation or timeout fence. See the reproducible CrewAI evaluation.

These probes measure the framework's lifecycle behavior in a minimal configuration. For production confidence, implement an application adapter that replaces your real consequential tools with the sentinel at dependency-injection time. See the adapter guide.

The same runner is available as a pytest fixture:

def test_agent_controls(agentbarrier):
    result = agentbarrier.verify_sync(MyApplicationAdapter())
    result.raise_for_failure()

CLI reports

agentbarrier verify myapp.agentbarrier_adapter:create_adapter \
  --approval-profile run-wide \
  --json build/agentbarrier.json \
  --junit build/agentbarrier.xml \
  --sarif build/agentbarrier.sarif

The target may be an adapter instance, adapter class, or zero-argument factory. A non-zero exit status is returned for failed or errored guarantees. --strict-skips also treats unsupported guarantees as a failure. See the CI guide for copy-ready GitHub Actions and pytest examples.

Guarantees

Scenario Capability Guarantee
approval_hold approval No effect commits before approval; one commits afterward.
rejection rejection Rejected actions never commit.
argument_binding argument_binding Executed arguments exactly match approved arguments.
replay replay Replaying a completed action does not commit it twice.
outcome_ambiguity outcome_ambiguity A lost post-commit response becomes UNKNOWN and is not retried blindly.
outcome_reconciliation outcome_reconciliation Bounded identity lookup distinguishes committed, absent, conflicting, and unavailable evidence.
cancellation cancellation Work cancelled after it starts cannot commit later.
timeout timeout Timed-out work cannot commit later.
parallel_barrier parallel_barrier Parallel effects follow the selected approval-barrier profile.
delegation delegation Parent rejection prevents every delegated child effect.
audit_receipts audit_receipts Requests and decisions have complete, action-bound receipts.

Unsupported capabilities are explicitly reported as skipped. They are never silently counted as passing.

The default run-wide profile intentionally requires a pending approval to hold all sibling side effects in the logical run. The per-action profile allows ungated siblings to proceed while the gated action remains held. Reports always record the selected profile so a passing result cannot silently change meaning.

Adapter contract

An adapter starts one or more ActionRequest objects using the supplied EffectProbe and returns a RunHandle. The handle exposes pending actions and lifecycle decisions. See agentbarrier.adapters.reference.ReferenceAdapter for the complete, safe implementation and docs/adapters.md for implementation rules.

Current framework results are recorded in the compatibility matrix. The same probe runs also produce versioned JSON evidence that CI checks against the rendered table and uploads for every supported Python version. The security boundary and limitations are defined in the threat model. Planned adapters and release priorities are public in the roadmap.

Safety

Sentinel tools write only to a temporary SQLite journal owned by the test run. They do not call a real API or modify production data. Do not replace a sentinel with a production tool when writing an adapter.

Research context

AgentBarrier is motivated by research showing that approval, cancellation, timeout, and replay controls can leak side effects across agent frameworks. The initial scenario vocabulary follows the failure classes in Stop Means Stop: Measuring and Repairing the Enforcement Gap in Agent-Framework Control Primitives (2026): https://arxiv.org/abs/2607.14166.

Development

uv sync --extra test --extra all
uv run ruff check .
uv run ruff format --check .
uv run mypy src
uv run pytest --cov=agentbarrier --cov-report=term-missing
uv run --isolated --extra test --extra crewai pytest tests/test_crewai_adapter.py
uv build
uv run twine check dist/*

Good first contributions include framework adapters, application examples, and deterministic reproductions of control failures. Start with the contribution guide or open a framework adapter request.

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentbarrier-0.3.0.tar.gz (878.4 kB view details)

Uploaded Source

Built Distribution

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

agentbarrier-0.3.0-py3-none-any.whl (66.0 kB view details)

Uploaded Python 3

File details

Details for the file agentbarrier-0.3.0.tar.gz.

File metadata

  • Download URL: agentbarrier-0.3.0.tar.gz
  • Upload date:
  • Size: 878.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for agentbarrier-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bf2f72b6b2af20807cfc7712c7dd20160d5ceebaf0eb5e9b33189be63bb7f836
MD5 1590c59c04c4fdd34366371e9fe6c09e
BLAKE2b-256 f1d9989f51217b49111378e92984296341509f9d1350648c3e97832e17e653bc

See more details on using hashes here.

File details

Details for the file agentbarrier-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: agentbarrier-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 66.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for agentbarrier-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eaefe323162f030d80a06eed364f000a7cdc5cf644eaf44f3825f9061fcf36bc
MD5 c4693d748b8c723a3b059d042fe2f62a
BLAKE2b-256 83f75a3bf1a38cfce6bdb96ded1a46b14d7a23021fb0eca146d4fd4652d3bbeb

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 Sentry Error logging StatusPage Status page