Synopsis
Description
Theserve 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
Eachserve 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 fromrunagent.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
Database Capacity Issues
Database Capacity Issues
Port Allocation Problems
Port Allocation Problems
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)
Agent Configuration Errors
Agent Configuration Errors
Import/Module Errors
Import/Module Errors
Best Practices
- Monitor Capacity: Regularly check
runagent db-status --capacity - Clean Up: Remove unused agents to free database slots
- Use Replace: When at capacity, replace oldest agents rather than failing
- Test Locally: Always test with
servebefore remote deployment - Version Control: Keep
runagent.config.jsonin 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
runagent run- Execute deployed agentsrunagent db-status- Check database statusrunagent delete- Remove agentsrunagent deploy- Remote deployment (coming soon)runagent logs- View logs (coming soon)