Skip to main content

Synopsis

Description

The serve command starts a local FastAPI server that automatically deploys your agent with database persistence, port allocation, and capacity management. It’s the primary command for local development and testing.

Options

Auto Port Allocation

The serve command automatically allocates ports starting from 8450:
  • Port Range: 8450-8454 (supports up to 5 agents)
  • Automatic Detection: Finds next available port if preferred port is busy
  • Conflict Resolution: Never conflicts with existing agents

Database Integration

Each serve command automatically:
  • Registers agent in local SQLite database
  • Manages capacity (maximum 5 agents)
  • Persists deployments between restarts
  • Tracks usage statistics

Capacity Management

Examples

Basic Usage

Advanced Usage

Startup Process

The serve command follows this process:
1

Startup Animation

Displays robotic runner animation (customizable with --animation-style)
2

Capacity Check

Verifies database capacity (5 agents max) or handles replacement
3

Agent Registration

Registers agent in database with unique ID and allocated port
4

Server Start

Starts FastAPI server with automatic configuration

Available Endpoints

Once running, your agent exposes these REST and WebSocket endpoints:

REST Endpoints

WebSocket Endpoints

Testing Your Agent

Health Check

Execute Agent

Using Python SDK

Using CLI

Output Information

Successful Startup

Capacity Warning

Replacement Success

Agent Configuration

The serve command reads from runagent.config.json:

Development Features

Automatic Framework Detection

Database Persistence

  • Agent registrations persist between restarts
  • Usage statistics are tracked
  • Port allocations are remembered

Error Handling

Clear error messages for common issues:

Integration with Other Commands

Database Management

Execution

Animation Styles

Customize the startup animation:

Troubleshooting

The serve command handles port conflicts automatically:
  • Starts from port 8450
  • Increments if port is busy
  • Shows allocated address in output
  • Maximum 5 agents (ports 8450-8454)

Best Practices

  1. Monitor Capacity: Regularly check runagent db-status --capacity
  2. Clean Up: Remove unused agents to free database slots
  3. Use Replace: When at capacity, replace oldest agents rather than failing
  4. Test Locally: Always test with serve before remote deployment
  5. Version Control: Keep runagent.config.json in version control

Performance Notes

  • Single Process: Each agent runs in a single FastAPI process
  • Port Per Agent: Each agent gets its own port for isolation
  • Database Tracking: Minimal overhead for registration and tracking
  • Auto Cleanup: Detect and handle stale agent registrations

See Also