Skip to main content

Deterministic safety layer for AI coding agents

Project description

Agent Circuit Breaker

Deterministic safety layer for AI coding agents.

Goal

Place an explicit safety checkpoint between AI agents and the operating system.

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 (recursive deletion, destructive SQL, accidental production access) while keeping false positives extremely low.


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 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

Why This Matters

Modern AI coding agents can:

  • Execute shell commands
  • Modify files
  • Write scripts
  • Interact with databases

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 catches these before they 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.0 Stable 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
  • 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
  • 308 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.0.1

Next: compatible patch and minor releases


Author

Sagar Chhatrala - GitHub


This is a stable deterministic safety gate 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.0.1.tar.gz (44.1 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.0.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_circuit_breaker-1.0.1.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for agent_circuit_breaker-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7134b672acca09488f7a6faad37b9048c94ee67613635fe13271e95e67159968
MD5 b4ad719a854f9af99e77f7512d0d801d
BLAKE2b-256 896790875eaf6c37ba6db5299d9f6aca6dcdcc140d35ca51446607f18ff066e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_circuit_breaker-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70abfc2004a54d61441b61657dfd86d837f6c1bbb9882fbf194a96d52232c385
MD5 6729253284a7a367d59ea84d2180360b
BLAKE2b-256 d18d76f5b694ee4738f8cc4ff0a2203203307fbac0f5d7d71f966812a958f870

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