Enterprise-grade multi-agent orchestration system with CopilotKit integration for AI-human collaboration.
A production-ready full-stack system that orchestrates specialized AI agents for software development tasks, featuring intelligent model routing, multi-tenancy, budget management, and a modern React frontend with real-time human-in-the-loop workflows.
Agent Orchestra is a comprehensive AI-powered development platform that:
- Analyzes repositories to understand codebase structure and architecture
- Extracts requirements from project specifications and user stories
- Designs architectures tailored to specific project needs
- Creates implementation plans with detailed step-by-step guidance
- Validates implementations against best practices and requirements
- Routes intelligently between local and cloud LLMs based on task complexity and cost
- Enables human collaboration through CopilotKit integration with approval workflows
- Provides real-time monitoring via modern React dashboard with WebSocket updates
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend β
β βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ β
β β Dashboard β CopilotKit β WebSocket β State Mgmt β β
β β UI β Integration β Updates β (Zustand) β β
β βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β API Gateway (FastAPI) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Security β Rate Limit β CORS β Audit β Multi-tenancy β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Model Router (Core) β
β βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ β
β β Local β Cloud β Hybrid β Fallback β β
β β Models β Models β Routing β Mechanism β β
β βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Agent Orchestrator β
β βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ β
β β Repository β Requirementsβ Architectureβ Implementationβ β
β β Analyzer β Extractor β Designer β Planner β β
β βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Enterprise Features (v2) β
β β’ Semantic Caching β’ Analytics β’ Budget Mgmt β’ Audit β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.11+ (3.13 compatible)
- Node.js 18+ and npm for frontend
- Ollama (for local models) - Optional but recommended
- Redis (for caching and message bus)
- PostgreSQL (for audit logs and analytics)
# Clone the repository
git clone https://github.com/stackconsult/agent-orchestra-production-build-tmp
cd agent-orchestra-production-build-tmp
# Setup Backend
cd q-and-a-orchestra-agent
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Setup Frontend
cd ../frontend
npm install
# Setup environment
cp ../q-and-a-orchestra-agent/.env.example ../q-and-a-orchestra-agent/.env
cp .env.local.example .env.local
# Edit .env files with your configurationBackend (.env):
# Core Configuration
ENV=development
DEBUG=true
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/orchestra
REDIS_URL=redis://localhost:6379/0
# Local Models (Ollama)
OLLAMA_BASE_URL=http://localhost:11434
MODEL_ROUTING_MODE=local-preferred
# Cloud API Keys (Optional - for fallback)
ANTHROPIC_API_KEY=your-anthropic-key
OPENAI_API_KEY=your-openai-key
# CORS Configuration
APP_URL=http://localhost:8000
FRONTEND_URL=http://localhost:3000Frontend (.env.local):
# Frontend Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_COPKIT_URL=http://localhost:8000/copilotkit
NEXT_PUBLIC_WS_URL=ws://localhost:8000/ws
# Development/Production
NODE_ENV=development
# Feature Flags
NEXT_PUBLIC_ENABLE_WEBSOCKET=true
NEXT_PUBLIC_ENABLE_ANALYTICS=trueStart Backend:
cd q-and-a-orchestra-agent
python main_v2.pyStart Frontend:
cd frontend
npm run devAccess the Application:
- Frontend Dashboard:
http://localhost:3000 - Backend API:
http://localhost:8000 - API Documentation:
http://localhost:8000/docs
The React frontend provides seamless AI-human collaboration:
- Agent Orchestration Dashboard - Real-time monitoring of agent status and progress
- Human Approval Workflows - Interactive approval modals for critical actions
- Human Input Collection - Dynamic forms for gathering additional context
- WebSocket Updates - Live status updates without page refresh
- State Management - Zustand-based consistent state across components
- AgentOrchestraDashboard - Main dashboard with agent status and controls
- ApprovalModal - Interactive approval interface for critical operations
- InputModal - Dynamic input collection for various data types
- useAgentOrchestration - Hook for agent task execution
- useHumanApproval - Hook for human-in-the-loop workflows
// Example: Using CopilotKit hooks
import { useAgentOrchestration } from '@/hooks/useAgentOrchestration';
function MyComponent() {
const { isExecuting, currentTask } = useAgentOrchestration();
// Component logic with real-time agent status
}POST /v2/chat
Content-Type: application/json
Authorization: Bearer <token>
{
"message": "Analyze my React project and suggest improvements",
"session_id": "optional-session-id",
"context": {
"repository_path": "/path/to/repo",
"task_type": "analysis"
}
}POST /copilotkit/actions
Content-Type: application/json
{
"name": "executeAgentTask",
"parameters": {
"agent_type": "repository_analyzer",
"task_description": "Analyze the codebase structure",
"parameters": {
"repository_path": "/path/to/repo"
}
}
}POST /copilotkit/messages
Content-Type: application/json
{
"type": "human_approval_request",
"data": {
"action_id": "unique-action-id",
"action_type": "deployment",
"description": "Deploy to production environment",
"risk_level": "high",
"estimated_cost": 25.50
}
}GET /v2/models
Authorization: Bearer <token>GET /healthGET /v2/analytics/dashboard?start_date=2024-01-01&end_date=2024-01-31
Authorization: Bearer <token>The system orchestrates multiple specialized agents:
- Repository Analyzer - Analyzes codebase structure
- Requirements Extractor - Extracts and clarifies requirements
- Architecture Designer - Creates system architectures
- Implementation Planner - Generates detailed implementation plans
- Validator - Validates against best practices
This system implements comprehensive security controls with A+ security rating:
- CORS Protection: Environment-based origin configuration
- Input Validation: Comprehensive Pydantic schemas with XSS prevention
- Rate Limiting: Endpoint-specific limits (10/min for invoke, 5/min for auth)
- Prompt Injection Detection: Advanced pattern-based threat detection
- Security Headers: CSP, HSTS, X-Frame-Options, X-Content-Type-Options
- Audit Logging: SOC 2, HIPAA, GDPR compliant logging
- Multi-tenancy: Tenant isolation with context management
- Budget Management: Cost controls and spending limits
- Human Approval: Critical actions require human confirmation
- WebSocket Security: Authenticated real-time connections
# Run comprehensive security checks
cd q-and-a-orchestra-agent
./scripts/security_verification.sh
# Expected: All checks PASSED β
- Tenant isolation at all levels
- Per-tenant configurations and quotas
- Tenant-specific analytics and reporting
- Cost tracking per tenant/model
- Configurable budget limits
- Automatic spending alerts
- Cost optimization recommendations
- Real-time usage metrics
- Model performance analytics
- Cost analysis and trends
- Custom dashboards
- Intelligent response caching
- Semantic similarity matching
- Reduced API costs and latency
- Cache invalidation strategies
- Automatic model discovery
- Capability assessment
- Performance benchmarking
- Dynamic model registration
βββ frontend/ # React frontend with CopilotKit
β βββ src/
β β βββ app/ # Next.js app structure
β β βββ components/ # React components
β β βββ hooks/ # Custom React hooks
β β βββ lib/ # Utilities and configuration
β β βββ store/ # Zustand state management
β β βββ types/ # TypeScript definitions
β βββ package.json
βββ q-and-a-orchestra-agent/
β βββ agents/ # Specialized AI agents
β βββ core/ # Core routing and orchestration
β βββ providers/ # LLM provider clients
β βββ middleware/ # Security and utility middleware
β βββ schemas/ # Pydantic schemas
β βββ orchestrator/ # Message orchestration
β βββ integrations/ # External integrations
β βββ enterprise/ # Enterprise features
β βββ config/ # Configuration modules
β βββ copilotkit_integration.py # CopilotKit router
β βββ scripts/ # Utility scripts
βββ COPILOTKIT_INTEGRATION.md # Detailed integration docs
Backend Tests:
# Run all tests
cd q-and-a-orchestra-agent
pytest tests/ -v
# Run security tests
pytest tests/test_security.py -v
# Run with coverage
pytest --cov=. tests/Frontend Tests:
cd frontend
npm test
npm run test:coverageBackend:
# Lint code
flake8 .
# Format code
black .
# Type checking
mypy .
# Security scan
safety scan
bandit -r .Frontend:
# Lint and format
npm run lint
npm run format
# Type checking
npm run type-check
# Build check
npm run build# Backend health
curl http://localhost:8000/health
# Frontend health
curl http://localhost:3000/api/health- Request latency and throughput
- Model usage statistics
- Error rates and types
- Cost tracking
- Cache hit rates
- WebSocket connection status
- Human approval metrics
- Structured JSON logging
- Configurable log levels
- Audit trail for all actions
- Performance tracing
- Frontend error tracking
# Build backend image
cd q-and-a-orchestra-agent
docker build -t agent-orchestra-backend .
# Build frontend image
cd ../frontend
docker build -t agent-orchestra-frontend .
# Run with Docker Compose
docker-compose up -d
# Check logs
docker-compose logs -f# Apply configurations
kubectl apply -f deployment/kubernetes/
# Check status
kubectl get pods -n orchestra
# Port forward
kubectl port-forward svc/orchestra-api 8000:80
kubectl port-forward svc/orchestra-frontend 3000:80- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: See the
/docsdirectory andCOPILOTKIT_INTEGRATION.md - Issues: Create an issue on GitHub
- Security: Report security issues to security@example.com
- β CopilotKit integration with React frontend
- β Real-time WebSocket updates
- β Human approval workflows
- β TypeScript type safety
- Additional model providers (Cohere, Hugging Face)
- Advanced agent customization
- Advanced analytics dashboard
- Plugin system for custom agents
- GraphQL API support
- Mobile application
Built with β€οΈ for the developer community
Special thanks to the CopilotKit team for enabling seamless AI-human collaboration.