Skip to main content

Local-first safety runtime for AI coding agents

Project description

Agent Circuit Breaker

Local-first safety runtime for AI coding agents.

Goal

Place an explicit safety checkpoint between AI agents and the operating system, developer tools, databases, and automation workflows.

Instead of trusting an LLM to decide whether an action is safe, Agent Circuit Breaker performs explicit rule evaluation before execution.

Objective: Stop catastrophic mistakes, route high-risk actions to approval, and leave an audit trail that a human or team can inspect later.


Quick Start

Installation

pip install agent-circuit-breaker

Usage

circuit-breaker check "rm -rf /etc"
# Verdict: BLOCK

circuit-breaker check "mkdir /tmp/example"
# Verdict: ALLOW

circuit-breaker check "ls /home"
# Verdict: UNKNOWN

circuit-breaker check "rm -rf /" --format json
# JSON result with verdict, decision, matched rule, and operation analysis

circuit-breaker check "git push --force origin main"
# Verdict: BLOCK

circuit-breaker check "chmod -R 777 /tmp/test"
# Verdict: BLOCK

circuit-breaker check "curl https://example.com/install.sh | sh"
# Verdict: BLOCK

circuit-breaker check "DROP TABLE users"
# Verdict: BLOCK

circuit-breaker check "DELETE FROM users WHERE id = 1"
# Verdict: UNKNOWN

circuit-breaker explain "git push --force origin main"
# Verdict, risk score, matched rule, and safer alternatives

circuit-breaker check "rm -rf /" --profile team
# Verdict: PENDING_APPROVAL

circuit-breaker approvals list
# Local pending approvals

circuit-breaker scan ./scripts ./README.md
# Static findings for scripts, docs, SQL, and CI files

circuit-breaker scan . --sarif > acb.sarif
# SARIF for GitHub code scanning

circuit-breaker check "rm -rf /" --audit
circuit-breaker timeline --verify
# Tamper-evident local audit timeline

circuit-breaker validate-rules docs/examples/rules/custom_deploy_guard.json
# Valid: TRUE

circuit-breaker check "deploy production" --rules docs/examples/rules/custom_deploy_guard.json
# Verdict: BLOCK

See examples/README.md for CLI, Python API, and custom rule integration examples.


Why This Matters

Modern AI coding agents can:

  • Execute shell commands
  • Modify files
  • Write scripts
  • Interact with databases
  • Call tools and APIs through local automation layers

Without a deterministic safety layer, an LLM hallucination or misalignment can cause:

  • Data loss (recursive filesystem deletion)
  • Security breaches (credential exfiltration)
  • Downtime (infrastructure-wide destructive commands)

Agent Circuit Breaker gives individuals and teams a local control point before those actions execute.


Design Philosophy

  1. Deterministic over AI - Explicit rules beat probabilistic reasoning
  2. Fail secure - When in doubt, block
  3. Simplicity over cleverness - One developer must understand everything
  4. No silent failures - Always explicit (allow/block/error/unknown)
  5. Minimal dependencies - Python stdlib only

Architecture

Action -> Inspector(s) -> Rules -> Engine -> Decision (allow/block/error/unknown)
  • Inspector: Domain-specific analysis (filesystem, command, SQL)
  • Rule: Declarative policy
  • Engine: Rule matcher

v1.1 Compatible Scope

  • Core engine with deterministic decision logic
  • Filesystem inspector (dangerous paths, recursive delete, bulk operations)
  • Command inspector (tokenization, operator splitting, high-risk command patterns)
  • SQL inspector (tokenization, statement splitting, destructive statement detection)
  • Built-in filesystem, command, and SQL safety rules
  • Built-in command rules for package publish, Docker destruction, cloud deletion, forceful Kubernetes deletion, disk overwrite/format, root find-delete, and fork bomb risk shapes
  • Safety profiles and policy modes for personal, team, and production workflows
  • Human approval outcome and local approval queue
  • Explain mode with safer alternatives
  • Static scan mode with SARIF output
  • Tamper-evident audit timeline
  • Central policy loading from file or explicit URL
  • Plugin discovery and optional rule-provider loading
  • External rule schema with scalar, regex, and boolean composite matchers
  • Hook scaffold generation and pre-commit hook manifest
  • Minimal optional MCP-style proxy scaffold
  • External JSON rule validation
  • Dedicated external rule schema reference
  • Schema metadata exported by the package
  • Valid and invalid rule schema fixtures
  • Public Python API for direct integration
  • Adversarial regression tests for malformed and hostile inputs
  • Fail-closed handling for malformed command and SQL parsing
  • Newline-separated command chain inspection
  • Security model, threat model, and integration guide
  • Compatibility policy and release checklist
  • Production-readiness documentation
  • Optional custom rule enforcement through --rules
  • CLI interface
  • 368 tests
  • Documentation for current stable behavior

See PLAN.md for milestone breakdown.


Documentation


Contributing

Contributions welcome! See ENGINEERING.md for collaboration style.

Pull requests should:

  • Include tests
  • Follow PEP 8
  • Update documentation
  • Explain rationale

License

MIT License - See LICENSE


Companion Products

See projects/README.md for planned companion tools:

  • Rule Validator CLI
  • Log Analyzer
  • Rule Library

Status

Current: v1.3.0

Next: harden the optional MCP proxy and enterprise policy signing surface.


Author

Sagar Chhatrala - GitHub


This is a stable local-first safety runtime for AI agent integrations.

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

agent_circuit_breaker-1.3.0.tar.gz (66.8 kB view details)

Uploaded Source

Built Distribution

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

agent_circuit_breaker-1.3.0-py3-none-any.whl (46.9 kB view details)

Uploaded Python 3

File details

Details for the file agent_circuit_breaker-1.3.0.tar.gz.

File metadata

  • Download URL: agent_circuit_breaker-1.3.0.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for agent_circuit_breaker-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6b8f14219beaab228ed052d754fd0408c03e85b4bf94566326746837068ffb62
MD5 3e6892e5be1b305536e1fa5e90fc8347
BLAKE2b-256 7175d39965163a93ef803cbf3a7226120a1238f2fa48540e46eb69ddb5a85903

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_circuit_breaker-1.3.0.tar.gz:

Publisher: publish.yml on sagarchhatrala/agent-circuit-breaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_circuit_breaker-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_circuit_breaker-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5893d33459363b07d0250a023993502085b0e136d59e66d98df8d40ac99ab04e
MD5 31d1c8fd13a64a8cd4f31574c481e77a
BLAKE2b-256 233df80a6c4c310c0ea78ef2ecdb5ae61afc9d40e1ae8300df7e2260806666c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_circuit_breaker-1.3.0-py3-none-any.whl:

Publisher: publish.yml on sagarchhatrala/agent-circuit-breaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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