Skip to content

Siddhant-K-code/ai-agent-orchestrator

Repository files navigation

AI Agent Orchestrator

A sophisticated multi-agent AI system built on Cloudflare Workers and Containers that orchestrates different specialized AI agents to collaborate on complex research and analysis tasks.

🚀 Architecture

The system consists of a main orchestrator service and three specialized agent containers:

Main Orchestrator (TypeScript/Hono)

  • Purpose: Coordinates agent communication and task distribution
  • Technology: Cloudflare Workers, Hono framework, TypeScript
  • Responsibilities: Request routing, response aggregation, error handling

Specialized Agents

1. 🧠 NLP Agent (Python)

  • Capabilities:
    • Text summarization using BART transformer
    • Sentiment analysis with RoBERTa
    • Named entity recognition with spaCy
    • Language detection
  • Technology: FastAPI, transformers, spaCy, NLTK, TextBlob

2. 🌐 Web Agent (Node.js)

  • Capabilities:
    • Web scraping and content extraction
    • Search result simulation
    • Content parsing with Readability
    • URL validation and metadata extraction
  • Technology: Node.js, Hono, Cheerio, Puppeteer, Readability

3. 📊 Analytics Agent (Go)

  • Capabilities:
    • Statistical analysis (mean, median, std dev)
    • Trend detection and correlation analysis
    • Data insights generation
    • Performance metrics calculation
  • Technology: Go, Gin framework, Gonum statistics

🎯 Use Cases

Research Assistant

Submit a research query and get:

  • Web search results with extracted content
  • Sentiment analysis of findings
  • Statistical analysis of data patterns
  • Comprehensive insights and trends

Content Analysis Pipeline

  • Extract and analyze text from multiple sources
  • Generate summaries and key insights
  • Identify correlations and patterns
  • Produce actionable intelligence

Data Intelligence Platform

  • Process structured and unstructured data
  • Generate statistical reports
  • Detect trends and anomalies
  • Provide automated insights

🔧 API Endpoints

Main Orchestrator

GET /

System information and available endpoints

GET /health

System health check with agent status

GET /agents

List all available agents and their capabilities

POST /research

Submit a comprehensive research request

Request Body:

{
  "query": "artificial intelligence in healthcare",
  "focus_areas": ["machine learning", "diagnostics"],
  "max_sources": 5,
  "include_sentiment": true,
  "include_analytics": true
}

Response:

{
  "success": true,
  "data": {
    "query": "artificial intelligence in healthcare",
    "summary": "AI in healthcare is transforming...",
    "sources": [...],
    "sentiment_analysis": {
      "score": 0.8,
      "label": "positive",
      "confidence": 0.95
    },
    "key_entities": [...],
    "analytics": {
      "statistics": {...},
      "trends": [...],
      "insights": [...]
    },
    "generated_at": "2025-06-24T20:15:30Z",
    "processing_time_ms": 3450
  }
}

Individual Agent Testing

POST /agents/nlp/test

Test NLP agent directly

POST /agents/web/test

Test Web agent directly

POST /agents/analytics/test

Test Analytics agent directly

🛠 Development

Prerequisites

  • Node.js 20+
  • pnpm
  • Docker (for container development)
  • Cloudflare Workers CLI (wrangler)

Setup

# Install dependencies
pnpm install

# Generate Cloudflare types
pnpm run cf-typegen

# Start development server
pnpm run dev

Testing

# Run all tests
pnpm test

# Run linting and type checking
pnpm run check

Container Development

Each agent can be developed and tested independently:

# Test NLP Agent locally
cd containers/nlp
pip install -r requirements.txt
python main.py

# Test Web Agent locally
cd containers/web
npm install
npm start

# Test Analytics Agent locally
cd containers/analytics
go mod download
go run .

🚀 Deployment

Cloudflare Workers

# Deploy to Cloudflare
pnpm run deploy

Container Requirements

  • Each container runs on port 8080
  • NLP Agent requires ~2GB RAM for transformer models
  • Web Agent needs internet access for scraping
  • Analytics Agent is lightweight and CPU-focused

📊 Performance Characteristics

Response Times (Typical)

  • Simple NLP tasks: 100-500ms
  • Web scraping (3-5 URLs): 2-5 seconds
  • Statistical analysis: 50-200ms
  • Full research pipeline: 3-10 seconds

Scalability

  • Horizontal scaling: Multiple container instances
  • Auto-scaling: Based on request volume
  • Resource isolation: Each agent in separate containers
  • Fault tolerance: Individual agent failures don't crash system

🔒 Security & Privacy

  • Container isolation: Each agent runs in isolated environment
  • No persistent storage: Stateless request processing
  • Input validation: Comprehensive request validation
  • Error sanitization: No sensitive data in error messages

🧪 Example Research Workflows

1. Market Research

curl -X POST {HOST}/research \
  -H "Content-Type: application/json" \
  -d '{
    "query": "electric vehicle market trends 2024",
    "max_sources": 10,
    "include_sentiment": true,
    "include_analytics": true
  }'

2. Technical Analysis

curl -X POST {HOST}/research \
  -H "Content-Type: application/json" \
  -d '{
    "query": "kubernetes security best practices",
    "focus_areas": ["container security", "network policies"],
    "max_sources": 7,
    "include_sentiment": false,
    "include_analytics": true
  }'

3. Content Intelligence

curl -X POST {HOST}/research \
  -H "Content-Type: application/json" \
  -d '{
    "query": "renewable energy adoption rates",
    "max_sources": 15,
    "include_sentiment": true,
    "include_analytics": true
  }'

📈 Monitoring & Observability

  • Built-in health checks for all agents
  • Performance metrics in responses
  • Error tracking with detailed error messages
  • Request tracing through the orchestration pipeline

🔮 Future Enhancements

  • Agent Plugin System: Dynamic agent registration
  • Caching Layer: Redis-based response caching
  • Streaming Responses: Real-time result streaming
  • Advanced ML Models: Integration with GPT/Claude APIs
  • Visual Analytics: Chart and graph generation
  • Multi-language Support: International content analysis

🤝 Contributing

This is a proof-of-concept demonstrating Cloudflare Containers for AI agent orchestration. The system showcases:

  • Microservice architecture with language-specific agents
  • Container orchestration for specialized AI workloads
  • Real-time collaboration between different AI capabilities
  • Scalable and fault-tolerant design patterns

Perfect for research institutions, content intelligence platforms, and organizations needing automated analysis workflows.

About

POC for cloudflare containers

Resources

Stars

Watchers

Forks

Contributors