Overview
Overview
Circuit Breaker was created to address the growing need for robust, AI-powered workflow management in modern applications. As applications increasingly incorporate AI capabilities, there’s a need for a framework that can:
- Seamlessly Integrate AI: Handle interactions with various LLM providers while maintaining clean separation of concerns
- Manage Complex Workflows: Provide a declarative way to define and manage state transitions with validation
- Ensure Reliability: Implement proper error handling, retries, and state management for AI operations
- Maintain Flexibility: Allow for custom executors and easy extension of functionality
Architecture
Circuit Breaker uses a hybrid architecture combining several powerful concepts:
1. Workflow Engine
The core workflow engine is based on Petri nets, providing:
- Formal verification capabilities
- Clear state management
- Transition validation
- Comprehensive event tracking
While basic Petri nets are not Turing complete, our implementation is closer to Colored Petri Nets (CPNs) or High-level Petri Nets, balancing theoretical power with practical utility.
2. Rules Engine
A unified system for managing:
- Validation rules
- Transition policies
- Business logic
- Error handling
The rules engine provides:
- Declarative rule definitions
- Complex rule chains
- Clear error reporting
- Rule reusability
3. AI Integration Layer
A flexible system for:
- Multiple LLM provider support
- Automatic model selection
- Tool integration
- Memory management
- Error handling with retries
4. Event System
Comprehensive tracking and auditing:
- State transition history
- Action execution logs
- Error tracking
- Audit trails
Design Philosophy
Circuit Breaker balances several key principles:
- Theoretical Soundness: Using formal methods (Petri nets) for workflow verification
- Practical Utility: Providing a clean, Ruby-like DSL for easy implementation
- Flexibility: Supporting custom executors and extensions
- Reliability: Implementing robust error handling and state management
This design allows Circuit Breaker to be:
- Expressive enough for complex business processes
- Analyzable for critical property verification
- Maintainable through the workflow DSL
- Extensible for various use cases