Robutler

Server Architecture

Production architecture and deployment patterns.

[!WARNING] 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

  1. Request arrives at FastAPI server
  2. Authentication validates API keys and user identity
  3. Routing selects agent based on URL path
  4. Context creates request context with user information
  5. Execution runs agent with skills and LLM integration
  6. 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

import { createAgentApp } from 'webagents/server';

const app = createAgentApp({
  title: 'Production Server',
  agents,
  enableCors: true,
  requestTimeoutMs: 300_000,
});

Production Patterns

Multi-Agent Server

import { BaseAgent } from 'webagents';
import { createAgentApp } from 'webagents/server';
import { serve } from 'webagents/server/node';

function createProductionServer() {
  const agents = [
    new BaseAgent({ name: 'support', model: 'openai/gpt-4o' }),
    new BaseAgent({ name: 'sales', model: 'openai/gpt-4o' }),
    new BaseAgent({ name: 'analyst', model: 'anthropic/claude-3-sonnet' }),
  ];
  return createAgentApp({
    title: 'Production Multi-Agent Server',
    agents,
    urlPrefix: '/api/v1',
  });
}

const app = createProductionServer();
await serve(app, { host: '0.0.0.0', port: 8000 });

Dynamic Agent Loading

import { createAgentApp } from 'webagents/server';

async function resolveAgent(agentName: string): Promise<BaseAgent | null> {
  const config = await loadAgentConfig(agentName);
  return config ? new BaseAgent(config) : null;
}

const app = createAgentApp({
  agents: staticAgents,
  dynamicAgents: resolveAgent,
});

Monitoring

Health Checks

Built-in endpoints (both SDKs):

GET /health              # Server health
GET /{agent}/health      # Agent health

Metrics

Enable Prometheus metrics:

// Coming soon — track at https://github.com/robutlerai/webagents/issues
// In TypeScript, expose metrics via a custom @http handler that reads
// from your own counters / OpenTelemetry exporter.

Access metrics at /metrics endpoint.

Logging

Configure structured logging:

import { pino } from 'pino';

const logger = pino({
  level: process.env.LOG_LEVEL ?? 'info',
});

Deployment

Production Server

import { serve } from 'webagents/server/node';

async function main() {
  const app = createProductionServer();
  await serve(app, { host: '0.0.0.0', port: 8000 });
}

main();

Security

API Authentication

import { BaseAgent } from 'webagents';
import { AuthSkill } from 'webagents/skills/auth';

const agent = new BaseAgent({
  name: 'secure-agent',
  model: 'openai/gpt-4o',
  skills: [new AuthSkill()],
});

CORS Configuration

import { createAgentApp } from 'webagents/server';

const app = createAgentApp({
  agents,
  enableCors: true,
  corsOrigins: ['https://yourdomain.com'],
});

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

import { createAgentApp } from 'webagents/server';

const app = createAgentApp({
  agents,
  requestTimeoutMs: 300_000,
  maxRequestSizeBytes: 10 * 1024 * 1024,
});

Best Practices

  1. Environment Variables - Use env vars for configuration
  2. Health Checks - Implement proper health endpoints
  3. Logging - Use structured logging for observability
  4. Resource Limits - Set appropriate timeouts and limits
  5. Monitoring - Enable metrics collection
  6. Security - Use authentication and CORS properly

See Also

On this page