Architecture
Overview
AgentFlow is structured as a layered system with clear separation of concerns.
Package Structure
| Package | Purpose |
|---|---|
| agentflow.core | Agent, orchestrator, wave resolver, pipeline, tier matrix |
| agentflow.comms | Intent classifier, delta codec, state dedup, predict cache |
| agentflow.llm | Model router with KeyPool, CircuitBreaker, RetryLLM |
| agentflow.security | RBAC, audit logging, encryption, canary tokens, output filter |
| agentflow.api | FastAPI server, middleware, persistent API |
| agentflow.db | SQLAlchemy models, repository pattern, engine config |
| agentflow.billing | Stripe BillingManager, WebhookHandler |
| agentflow.enterprise | SSO/OIDC, SLA monitoring, compression proxy |
| agentflow.dashboard | Streamlit pulse dashboard |
Execution Model
Sequential (Starter Tier)
Agents execute one at a time in dependency order. Suitable for simple workflows.
Parallel Waves (Pro / Enterprise)
The wave resolver analyses agent dependencies and groups independent agents into waves. Each wave executes in parallel, with results feeding into the next wave.
Communication Compression
- Intent Classification -- TF-IDF + Logistic Regression classifies message intent
- Delta Compression -- only transmits changes between states using JSON patches
- State Deduplication -- replaces repeated values with references
- Predictive Caching -- pre-computes likely responses based on message patterns
Database
Seven tables managed by SQLAlchemy 2.0 with async support: tenants, users, pipeline_runs, agent_events, predict_templates, audit_entries, dedup_states.