Serverless
Serverless Deployment
Deploy agents to AWS Lambda, Google Cloud Functions, or Azure Functions. The SDK automatically detects serverless environments and adapts accordingly.
Serverless Overview
Benefits:
- Auto-scaling
- Pay per invocation
- No server management
- High availability
AWS Lambda
Lambda Handler
handler.py:
Lambda requirements.txt
Lambda with API Gateway (Serverless Framework)
Lambda Request Flow

Google Cloud Functions
Cloud Functions Handler
main.py:
Cloud Functions requirements.txt
Deploying to Cloud Functions (Gen 2)
Azure Functions
Azure Functions Handler
function_app/__init__.py:
Azure Functions requirements.txt
function.json
host.json
Testing Serverless
Local Testing with swaig-test
Testing Deployed Endpoints
Authentication
The SDK automatically enables HTTP Basic Authentication. You can:
- Let the SDK generate credentials - Secure random credentials are created automatically
- Set your own credentials - Via environment variables:
Force Mode Override
For testing, you can force a specific execution mode:
Serverless Best Practices
Cold Starts
- Keep dependencies minimal
- Initialize agent outside handler function
- Use provisioned concurrency for low latency
Timeouts
- Set appropriate timeout (Lambda: up to 15 min)
- Account for external API calls
- Monitor and optimize slow functions
Memory
- Allocate sufficient memory
- More memory = more CPU in Lambda
- Monitor memory usage
State
- Design for statelessness
- Use external storage for persistent data
- Don’t rely on local filesystem
Multi-Agent Serverless
Deploy multiple agents with AgentServer:
Environment Detection
The SDK detects serverless environments automatically: