Skip to main content

Deterministic execution authorization for AI agent side effects. CapFence gates tool calls before execution, fail-closes unsafe requests, and records decisions for replay.

Project description

CapFence

Deterministic execution authorization for AI agent side effects.

CapFence intercepts agent tool calls before execution, evaluates explicit policy, fail-closes unsafe requests, and records decisions for replay. Models may propose actions. CapFence authorizes side effects.

Prompts are not security boundaries. CapFence removes the LLM from the authorization path.

PyPI version Python versions License: MIT CI Status

Agent -> Tool Call -> CapFence Policy -> Allow / Deny / Approval -> Audit + Replay

What Happens At Execution Time

  1. An agent requests a tool call.
  2. CapFence receives the capability, actor, payload, and environment.
  3. Policy returns allow, deny, or require_approval.
  4. Unsafe requests are blocked before the downstream system is invoked.
  5. The decision is recorded for audit and deterministic replay.

Install

pip install capfence

First Blocked Action

Define a policy:

deny:
  - capability: shell.exec.production
    contains: "rm -rf"

allow:
  - capability: shell.exec.readonly

Evaluate before execution:

from capfence import ActionEvent, ActionRuntime

runtime = ActionRuntime.from_policy("policies/shell.yaml")

event = ActionEvent.create(
    actor="ops-agent",
    resource="shell",
    action="exec",
    environment="production",
    payload={"command": "rm -rf /var/lib/postgresql"},
)

verdict = runtime.execute(event)

if not verdict.authorized:
    raise PermissionError(f"Blocked before execution: {verdict.reason}")

Expected result:

decision: DENY
reason: policy_deny
tool_invoked: false

Replay the decision:

capfence replay audit.jsonl --policy policies/shell.yaml

Replay output:

Recorded: shell.exec.production
Original: DENY
Replayed: DENY
Changed:  false

Use CapFence For

  • shell.exec boundaries before a process is spawned.
  • MCP tool authorization before the upstream server receives a request.
  • Filesystem scope enforcement before secrets or repo-external paths are read.
  • Database write and schema-change controls before queries execute.
  • Payment or API action thresholds before external state changes.

CapFence Is Not

  • An AI governance platform.
  • An observability product.
  • An orchestration framework.
  • A prompt guardrail.
  • An AI judge.
  • A compliance dashboard.

Core Docs

Status

CapFence is pre-1.0 public beta infrastructure. The core local YAML policy runtime is intended for production pilots, while framework adapters, policy packs, external policy backends, and release automation should be validated in your environment before high-risk use.

CapFence controls the gated tool path. It does not replace sandboxing, secrets management, network segmentation, downstream IAM, or database-native controls.

Capability Maturity
Local YAML policy evaluation Beta
Audit hash chaining and replay Beta
LangChain, LangGraph, CrewAI, OpenAI Agents SDK adapters Beta
MCP, PydanticAI, LlamaIndex, AutoGen adapters Experimental
Starter policy packs and OPA backend path Experimental

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

capfence-0.8.3.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

capfence-0.8.3-py3-none-any.whl (88.1 kB view details)

Uploaded Python 3

File details

Details for the file capfence-0.8.3.tar.gz.

File metadata

  • Download URL: capfence-0.8.3.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for capfence-0.8.3.tar.gz
Algorithm Hash digest
SHA256 071cf9d06a0149a450a286b89744ca7a916673b83f318317d040d00b9e76c120
MD5 3c02bce522e584277e6b7a8337865f53
BLAKE2b-256 8d67ee5d628b16d0c7b4ed2e8aa655a7a3da63b355f3851e4cdbfed1ad5ecf49

See more details on using hashes here.

File details

Details for the file capfence-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: capfence-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 88.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for capfence-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 888408557d5fa486298605c8a10e70714809e9deec48b6583cff8cb9ad7216c0
MD5 94ec0cd7ec2492419d38dc548d074847
BLAKE2b-256 74899745ad15f5e2c4ac24c8548bf906d870bba313f6fffc7868d2e1c32ca94e

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