Server Architecture
Production server architecture and deployment patterns for Robutler V2.
Beta Software
Robutler is in beta. APIs may change. Test thoroughly before production deployment.
Architecture Overview
The Robutler server is built on FastAPI with these core components:
- Agent Manager - Routes requests to appropriate agents
- Skill Registry - Manages agent capabilities and tools
- Context Manager - Handles request context and user sessions
- LLM Proxy - Integrates with OpenAI, Anthropic, and other providers
Request Flow
- Request arrives at FastAPI server
- Authentication validates API keys and user identity
- Routing selects agent based on URL path
- Context creates request context with user information
- Execution runs agent with skills and LLM integration
- Response returns streaming or batch results
Configuration
Environment Variables
# Server
ROBUTLER_HOST=0.0.0.0
ROBUTLER_PORT=8000
ROBUTLER_LOG_LEVEL=INFO
# LLM Providers
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key
# Optional Features
DATABASE_URL=postgresql://user:pass@host/db
REDIS_URL=redis://localhost:6379
PROMETHEUS_ENABLED=true
Server Configuration
from robutler.server.core.app import create_server
server = create_server(
title="Production Server",
agents=agents,
enable_monitoring=True,
enable_cors=True,
request_timeout=300
)
Production Patterns
Multi-Agent Server
from robutler.agents import BaseAgent
from robutler.server.core.app import create_server
def create_production_server():
agents = [
BaseAgent(name="support", model="openai/gpt-4o"),
BaseAgent(name="sales", model="openai/gpt-4o"),
BaseAgent(name="analyst", model="anthropic/claude-3-sonnet")
]
return create_server(
title="Production Multi-Agent Server",
agents=agents,
url_prefix="/api/v1",
enable_monitoring=True
)
if __name__ == "__main__":
import uvicorn
server = create_production_server()
uvicorn.run(server.app, host="0.0.0.0", port=8000, workers=4)
Dynamic Agent Loading
async def resolve_agent(agent_name: str):
"""Load agent configuration from database/API"""
config = await load_agent_config(agent_name)
if config:
return BaseAgent(**config)
return None
server = create_server(
agents=static_agents,
dynamic_agents=resolve_agent
)
Monitoring
Health Checks
Metrics
Enable Prometheus metrics:
Access metrics at /metrics endpoint.
Logging
Configure structured logging:
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
Deployment
Production Server
import uvicorn
from robutler.server.core.app import create_server
def main():
server = create_production_server()
uvicorn.run(
server.app,
host="0.0.0.0",
port=8000,
workers=4,
access_log=True
)
if __name__ == "__main__":
main()
Security
API Authentication
# Using AuthSkill for automatic authentication
from robutler.agents.skills.robutler.auth import AuthSkill
agent = BaseAgent(
name="secure-agent",
model="openai/gpt-4o",
skills={"auth": AuthSkill()}
)
CORS Configuration
Performance Tuning
Concurrency
# Multiple workers for CPU-bound tasks
uvicorn main:server.app --workers 4 --worker-class uvicorn.workers.UvicornWorker
# Async for I/O-bound tasks
uvicorn main:server.app --loop asyncio --http httptools
Resource Limits
Best Practices
- Environment Variables - Use env vars for configuration
- Health Checks - Implement proper health endpoints
- Logging - Use structured logging for observability
- Resource Limits - Set appropriate timeouts and limits
- Monitoring - Enable metrics collection
- Security - Use authentication and CORS properly
See Also
- Server Overview - Basic server setup
- Dynamic Agents - Runtime agent loading
- Agent Skills - Agent capabilities