How sagarchhatrala/agent-circuit-breaker works
Agent Circuit Breaker is a local-first runtime safety gate for agent actions and MCP calls. Its main workflow accepts an action through the CLI, API, or an adapter; evaluates it with deterministic inspection and rules; then returns a fail-closed verdict, with trajectory checks for risks spanning a run. The graph also captures documented approvals, audit/ledger support, the async guard pipeline, MCP interception, and optional telemetry. Edges use sampled source references or README statements; unsampled subsystems are shown without speculative internal wiring.
Main entry points: api.py Python API · engine.py Decision Engine · proxy.py MCP Proxy · cli.py CLI
Components 24
Entry Points
- CLI
agent_circuit_breaker/cli.py - Python API
agent_circuit_breaker/api.py - MCP Proxy
agent_circuit_breaker_mcp/proxy.py
Safety Evaluation
- Decision Engine
agent_circuit_breaker/engine.py - Command Inspector
agent_circuit_breaker/inspectors/command.py - Filesystem Inspector
agent_circuit_breaker/inspectors/filesystem.py - SQL Inspector
agent_circuit_breaker/inspectors/sql.py - Built-in Rules
agent_circuit_breaker/rules/builtin_rules.py - Rule Loader
agent_circuit_breaker/rules/loader.py - Policy Packs
agent_circuit_breaker/policy.py - Decision Model
agent_circuit_breaker/decision.py
Run Safety
- Trajectory Analysis
agent_circuit_breaker/trajectory.py - Async Pipeline
agent_circuit_breaker/core/pipeline.py - Action Context
agent_circuit_breaker/core/context.py - Guard Set
agent_circuit_breaker/guards
Review and State
- Approvals
agent_circuit_breaker/approvals.py - Audit Records
agent_circuit_breaker/audit.py - Run Ledger
agent_circuit_breaker/ledger.py - Circuit State
agent_circuit_breaker/state/manager.py - Secret Taint
agent_circuit_breaker/taint.py
Adapters and Telemetry
- MCP Security
agent_circuit_breaker_mcp/security.py - Native Hooks
agent_circuit_breaker/hooks_native.py - Telemetry
agent_circuit_breaker/observability
Other components
- Agent or User
Connections 26
- Agent or User → CLI: submits action
- Agent or User → Python API: submits action
- CLI → Decision Engine: evaluates action
agent_circuit_breaker/cli.py - Python API → Decision Engine: evaluates action
agent_circuit_breaker/api.py - Decision Engine → Command Inspector: normalizes and matches
- Built-in Rules → Command Inspector: analyzes commands
agent_circuit_breaker/rules/builtin_rules.py - Built-in Rules → Filesystem Inspector: checks filesystem risks
agent_circuit_breaker/rules/builtin_rules.py - Built-in Rules → SQL Inspector: checks SQL risks
agent_circuit_breaker/rules/builtin_rules.py - Rule Loader → Decision Engine: builds rules
agent_circuit_breaker/rules/loader.py - Policy Packs → Rule Loader: loads policy rules
agent_circuit_breaker/policy.py - Decision Engine → Decision Model: returns verdict
- CLI → Approvals: routes pending
agent_circuit_breaker/cli.py - CLI → Trajectory Analysis: evaluates run
agent_circuit_breaker/cli.py - Python API → Trajectory Analysis: evaluates trajectory
agent_circuit_breaker/api.py - Python API → Rule Loader: loads rules
agent_circuit_breaker/api.py - MCP Proxy → Python API: inspects tool calls
agent_circuit_breaker_mcp/proxy.py - MCP Proxy → Trajectory Analysis: tracks trajectories
agent_circuit_breaker_mcp/proxy.py - MCP Proxy → Secret Taint: checks taint
agent_circuit_breaker_mcp/proxy.py - MCP Proxy → MCP Security: uses security checks
agent_circuit_breaker_mcp/proxy.py - Async Pipeline → Action Context: scopes evaluation
agent_circuit_breaker/core/pipeline.py - Async Pipeline → Guard Set: dispatches guards
agent_circuit_breaker/core/pipeline.py - Async Pipeline → Telemetry: emits events
agent_circuit_breaker/core/pipeline.py - Trajectory Analysis → Circuit State: tracks run state
- Approvals → Audit Records: records decisions
- Approvals → Run Ledger: preserves review context
- Native Hooks → Async Pipeline: integrates with pipeline