Metadata-Version: 2.4
Name: agentflow-sdk
Version: 0.2.1
Summary: AI-Native Communication Intelligence for Multi-Agent Systems
Author: Sedge5 Technology Solutions
License: Proprietary
Project-URL: Homepage, https://agentflow.io
Project-URL: Documentation, https://agentflow.io/docs/
Project-URL: Repository, https://github.com/sedge5/agentflow
Keywords: ai,agents,orchestration,multi-agent,llm,compression
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0
Requires-Dist: structlog>=23.0
Requires-Dist: fastapi>=0.100
Requires-Dist: uvicorn>=0.23
Requires-Dist: msgpack>=1.0
Requires-Dist: jsonpatch>=1.33
Requires-Dist: scikit-learn>=1.3
Requires-Dist: sqlalchemy[asyncio]>=2.0
Requires-Dist: aiosqlite>=0.20
Requires-Dist: alembic>=1.13
Requires-Dist: stripe>=8.0
Requires-Dist: deepdiff>=7.0
Requires-Dist: cryptography>=42.0
Requires-Dist: authlib>=1.7
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=1.0; extra == "dev"
Requires-Dist: httpx>=0.27; extra == "dev"
Provides-Extra: postgres
Requires-Dist: asyncpg>=0.29; extra == "postgres"
Provides-Extra: dashboard
Requires-Dist: streamlit>=1.30; extra == "dashboard"
Requires-Dist: plotly>=5.20; extra == "dashboard"

# AgentFlow

**AI-Native Communication Intelligence for Multi-Agent Systems**

AgentFlow is a multi-agent orchestration platform with an intelligent communication layer that reduces LLM API costs by 40-70% through intent classification, predictive caching, delta encoding, and state deduplication.

## Quick Start

```bash
pip install agentflow
```

### Define and run a pipeline

```python
from agentflow import Agent, Pipeline, Orchestrator

agent_a = Agent("researcher", tier=1)
agent_b = Agent("analyst", tier=1, depends_on=["researcher"])
agent_c = Agent("writer", tier=2, depends_on=["analyst"])

pipeline = Pipeline()
pipeline.add_agent(agent_a)
pipeline.add_agent(agent_b)
pipeline.add_agent(agent_c)

orchestrator = Orchestrator(pipeline)
results = orchestrator.run("Analyse steel supply chain risks")
```

### Classify agent intents

```python
from agentflow.comms.intent_classifier import IntentClassifier

classifier = IntentClassifier()
classifier.load("data/intent_model.pkl")

result = classifier.classify("what is the current throughput")
print(result)  # {"intent": "query", "confidence": {"query": 0.77, ...}}
```

### Start the API server

```bash
# In-memory (development)
AGENTFLOW_ADMIN_KEY=your-key uvicorn agentflow.api.server:create_app --factory --host 0.0.0.0 --port 8100

# With persistence (production)
AGENTFLOW_ADMIN_KEY=your-key AGENTFLOW_DATABASE_URL=sqlite+aiosqlite:///agentflow.db uvicorn agentflow.api.db_app:create_persistent_app --factory --host 0.0.0.0 --port 8100
```

### API authentication

All endpoints (except /health) require an API key header:

```bash
curl -H "X-API-Key: your-key" http://localhost:8100/events/summary
```

## Architecture

AgentFlow has four layers:

**Layer 1 — Orchestration:** Wave-based parallel execution, dependency resolution, fault tolerance, multi-provider LLM routing with circuit breaker and key rotation.

**Layer 2 — Communication Intelligence:** Intent classification (TF-IDF + logistic regression, 99.96% accuracy), delta encoding (RFC 6902 JSON Patch + msgpack), state deduplication (content-addressed SHA-256), predictive caching (structural template learning).

**Layer 3 — Observability:** AgentPulse per-agent cost attribution, compression metrics, intent distribution analytics, Streamlit dashboard.

**Layer 4 — Enterprise:** RBAC (admin/operator/viewer), rate limiting, output filtering, CompressProxy for legacy integration, Docker + Helm deployment.

## Database

AgentFlow uses SQLAlchemy 2.0 async with Alembic migrations. SQLite for development, PostgreSQL for production.

```bash
# Run migrations
alembic upgrade head

# Switch to PostgreSQL
export AGENTFLOW_DATABASE_URL=postgresql+asyncpg://user:pass@host/agentflow
alembic upgrade head
```

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | /health | Health check |
| POST | /events/record | Record an agent event |
| GET | /events/summary | Tenant-wide summary |
| GET | /events/agent/{id} | Per-agent metrics |
| GET | /events/intents | Intent distribution |
| POST | /pipelines | Create pipeline run |
| GET | /pipelines/{id} | Get pipeline status |
| PUT | /pipelines/{id} | Update pipeline |
| POST | /classify | Classify intent |
| POST | /classify/train | Train classifier |
| POST | /dedup/store | Store content |
| GET | /dedup/resolve/{hash} | Resolve by hash |
| POST | /predict/observe | Record template |
| GET | /predict/template/{id} | Get prediction |
| GET | /audit | Audit trail |
| GET | /costs/summary | Cost breakdown |

## Security

- API key authentication (SHA-256 hashed, never stored in plaintext)
- Role-based access control (admin, operator, viewer)
- Per-endpoint permission mapping
- Rate limiting with burst detection
- Output filtering (prompt leak and PII detection)
- Input sanitisation
- Canary token detection
- Request signing
- AES-GCM encryption at rest
- Row-level tenant isolation
- Audit trail on all operations
- Soft deletes (GDPR-friendly)

## Configuration

Environment variables:

| Variable | Description | Default |
|----------|-------------|---------|
| AGENTFLOW_ADMIN_KEY | Admin API key (required) | — |
| AGENTFLOW_OPERATOR_KEY | Operator API key | — |
| AGENTFLOW_VIEWER_KEY | Viewer API key | — |
| AGENTFLOW_DATABASE_URL | Database connection string | sqlite+aiosqlite:///agentflow.db |
| STRIPE_SECRET_KEY | Stripe API key | — |
| STRIPE_WEBHOOK_SECRET | Stripe webhook secret | — |

## Installation with extras

```bash
pip install agentflow[postgres]    # PostgreSQL support
pip install agentflow[dashboard]   # Streamlit dashboard
pip install agentflow[dev]         # Development tools
```

## Pricing

AgentFlow is a paid product with three tiers. There is no free tier — the orchestrator is the core USP.

Starter (69/month): 100K messages, 20 agents, sequential execution + intent classification.
Pro (199/month): 1M messages, 50 agents, parallel wave execution + full compression.
Enterprise (599/month): Unlimited, self-hosted option, SSO/RBAC, SLA.

| Tier | Price | Messages/month | Agents | Execution |
|------|-------|---------------|--------|-----------|
| Starter | 79/month | 100,000 | 20 | Sequential |
| Pro | 249/month | 1,000,000 | 50 | Parallel (wave-based) |
| Enterprise | 799/month | Unlimited | Unlimited | Parallel + self-hosted |

## License

Proprietary — Sedge5 Technology Solutions
