Environment Variables Reference
Complete reference of all environment variables for configuring AgentField control plane and agents
This page provides a complete reference of environment variables for building and deploying multi-agent systems with AgentField.
Configuration Precedence
All AgentField components follow this configuration order (highest to lowest priority):
- Environment variables (overrides everything)
- Config file (
agentfield.yamlor viaAGENTFIELD_CONFIG_FILE) - Code defaults (fallback values)
Quick Find
Common variables you'll need for different scenarios:
| Scenario | Essential Variables |
|---|---|
| Local Development | AGENTFIELD_PORT, AGENTFIELD_STORAGE_MODE=local |
| Production Control Plane | AGENTFIELD_DATABASE_URL, AGENTFIELD_PORT, AGENTFIELD_STORAGE_MODE=postgres |
| Containerized Agents | AGENT_CALLBACK_URL, PORT, OPENAI_API_KEY |
| Python Agent Performance | AGENTFIELD_ASYNC_MAX_CONCURRENT_EXECUTIONS, UVICORN_WORKERS |
| Go Agent AI Integration | OPENAI_API_KEY or OPENROUTER_API_KEY, AI_MODEL |
Control Plane Configuration
Essential Server Settings
These variables configure the AgentField control plane server.
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_PORT | integer | 8080 | HTTP server port where control plane listens |
AGENTFIELD_MODE | string | local | Deployment mode: local (single machine) or cloud (distributed) |
AGENTFIELD_CONFIG_FILE | string | ./config/agentfield.yaml | Path to YAML configuration file |
AGENTFIELD_HOME | string | ~/.agentfield | AgentField home directory for data and config |
Example: Basic Setup
AGENTFIELD_PORT=8080
AGENTFIELD_MODE=localSee also: af server command, CLI Configuration
Storage Configuration
Control where AgentField stores its data (agents, executions, workflows).
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_STORAGE_MODE | string | local | Storage backend: local (SQLite+BoltDB), postgres, or cloud |
AGENTFIELD_STORAGE_LOCAL_DATABASE_PATH | string | ./agentfield_local.db | SQLite database file path (local mode only) |
AGENTFIELD_STORAGE_LOCAL_KV_STORE_PATH | string | ./agentfield_local.bolt | BoltDB key-value store path (local mode only) |
Production Recommendation
Use storage-mode=postgres for production deployments. Local storage (SQLite) is intended for development only and doesn't support concurrent access or high availability.
Example: Local Development
AGENTFIELD_STORAGE_MODE=local
AGENTFIELD_STORAGE_LOCAL_DATABASE_PATH=/var/agentfield/data.dbExample: Production PostgreSQL
AGENTFIELD_STORAGE_MODE=postgres
AGENTFIELD_DATABASE_URL="postgres://user:pass@db.example.com:5432/agentfield?sslmode=require"See also: Production Best Practices, CLI Configuration
PostgreSQL Configuration
For production deployments using PostgreSQL as the storage backend.
Connection String
Three Ways to Set Connection
You can use any of these three variables - they all work the same way:
AGENTFIELD_DATABASE_URL(recommended)AGENTFIELD_POSTGRES_URLAGENTFIELD_STORAGE_POSTGRES_URL
| Variable | Type | Required | Description |
|---|---|---|---|
AGENTFIELD_DATABASE_URL | string | Yes | Full PostgreSQL connection string Format: postgres://user:pass@host:port/db?sslmode=disable |
Example:
AGENTFIELD_DATABASE_URL="postgres://agentfield:password@db.example.com:5432/agentfield?sslmode=require"Connection Components
Alternatively, configure PostgreSQL using individual components:
| Variable | Type | Description |
|---|---|---|
AGENTFIELD_STORAGE_POSTGRES_HOST | string | PostgreSQL server hostname or IP |
AGENTFIELD_STORAGE_POSTGRES_PORT | integer | PostgreSQL server port (typically 5432) |
AGENTFIELD_STORAGE_POSTGRES_DATABASE | string | Database name |
AGENTFIELD_STORAGE_POSTGRES_USER | string | PostgreSQL username |
AGENTFIELD_STORAGE_POSTGRES_PASSWORD | string | PostgreSQL password |
AGENTFIELD_STORAGE_POSTGRES_SSLMODE | string | SSL mode: disable, require, verify-ca, or verify-full |
Example: Component-based Configuration
AGENTFIELD_STORAGE_MODE=postgres
AGENTFIELD_STORAGE_POSTGRES_HOST=db.example.com
AGENTFIELD_STORAGE_POSTGRES_PORT=5432
AGENTFIELD_STORAGE_POSTGRES_DATABASE=agentfield
AGENTFIELD_STORAGE_POSTGRES_USER=agentfield
AGENTFIELD_STORAGE_POSTGRES_PASSWORD=password
AGENTFIELD_STORAGE_POSTGRES_SSLMODE=requirePerformance Tuning
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_STORAGE_POSTGRES_MAX_CONNECTIONS | integer | 25 | Maximum database connection pool size |
AGENTFIELD_STORAGE_POSTGRES_MAX_IDLE_CONNECTIONS | integer | 5 | Maximum idle connections to keep open |
AGENTFIELD_STORAGE_POSTGRES_CONNECTION_TIMEOUT | duration | 30s | Timeout for establishing database connections |
AGENTFIELD_STORAGE_POSTGRES_QUERY_TIMEOUT | duration | 30s | Timeout for individual database queries |
High-Traffic Deployments
For production systems handling 100+ agents or high request volumes, increase connection pool size:
AGENTFIELD_STORAGE_POSTGRES_MAX_CONNECTIONS=100
AGENTFIELD_STORAGE_POSTGRES_MAX_IDLE_CONNECTIONS=25Duration Format: Use Go duration syntax: 30s, 5m, 1h30m
See also: Production Best Practices
Web UI Configuration
Control the built-in AgentField dashboard.
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_UI_ENABLED | boolean | true | Enable/disable the built-in web dashboard |
AGENTFIELD_UI_DIST_PATH | string | ./web/client/dist | Path to UI built assets (production mode) |
Example: API-Only Deployment (No UI)
AGENTFIELD_UI_ENABLED=falseAPI & Security Configuration
Configure CORS settings for the AgentField API.
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_API_CORS_ALLOWED_ORIGINS | string | http://localhost:3000,http://localhost:5173,http://localhost:8080 | CORS allowed origins (comma-separated) |
AGENTFIELD_API_CORS_ALLOWED_METHODS | string | GET,POST,PUT,DELETE,OPTIONS | CORS allowed HTTP methods (comma-separated) |
AGENTFIELD_API_CORS_ALLOWED_HEADERS | string | Origin,Content-Type,Accept,Authorization,X-Requested-With | CORS allowed headers (comma-separated) |
AGENTFIELD_API_CORS_EXPOSED_HEADERS | string | Content-Length,X-Total-Count | CORS exposed headers (comma-separated) |
AGENTFIELD_API_CORS_ALLOW_CREDENTIALS | boolean | true | Allow cookies and credentials in CORS requests |
Example: Production CORS Setup
AGENTFIELD_API_CORS_ALLOWED_ORIGINS=https://app.example.com,https://admin.example.com
AGENTFIELD_API_CORS_ALLOW_CREDENTIALS=truePython SDK Configuration
Agent Server Settings
Configure how Python agents expose their HTTP server.
| Variable | Type | Default | Description |
|---|---|---|---|
AGENT_CALLBACK_URL | string | (auto-discovered) | Critical for containers: URL where control plane can reach this agent Example: http://my-agent:8000 |
PORT | integer | 8000 | Agent server port (standard for Railway, Heroku, Render) |
AGENTFIELD_AUTO_PORT | boolean | false | Enable automatic port assignment (useful for local multi-agent testing) |
AGENTFIELD_AGENT_MAX_CONCURRENT_CALLS | integer | (varies) | Maximum concurrent calls this agent can handle |
Docker/Kubernetes: Must Set AGENT_CALLBACK_URL
When running agents in containers, you MUST set AGENT_CALLBACK_URL to the network-accessible URL so the control plane can call back to your agent.
Common patterns:
- Docker Compose:
http://agent-service-name:8000 - Kubernetes:
http://agent-service.namespace.svc.cluster.local:8000 - Docker Desktop:
http://host.docker.internal:8000(agent on host, control plane in container)
See Docker Deployment Guide for detailed examples.
Example: Containerized Agent
AGENT_CALLBACK_URL=http://my-agent.internal:8000
PORT=8000Example: Local Testing with Multiple Agents
AGENTFIELD_AUTO_PORT=true # Automatically assigns ports 8000, 8001, 8002...See also: Python SDK Configuration, Docker Networking
Async Execution Performance
Control how Python agents poll the control plane for execution results.
Polling Intervals
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_ASYNC_INITIAL_POLL_INTERVAL | float | 0.03 | Initial poll interval in seconds (30ms) - very fast for quick tasks |
AGENTFIELD_ASYNC_FAST_POLL_INTERVAL | float | 0.08 | Fast poll interval (80ms) - for tasks under 1 second |
AGENTFIELD_ASYNC_MEDIUM_POLL_INTERVAL | float | 0.4 | Medium poll interval (400ms) - for tasks under 10 seconds |
AGENTFIELD_ASYNC_SLOW_POLL_INTERVAL | float | 1.5 | Slow poll interval (1.5s) - for long-running tasks |
AGENTFIELD_ASYNC_MAX_POLL_INTERVAL | float | 4.0 | Maximum poll interval (4s) - prevents excessive polling |
Adaptive Polling
The Python SDK uses adaptive polling - it starts fast and gradually slows down if the execution takes longer. These defaults work well for most use cases. Only tune if you have specific latency requirements.
Timeouts
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_ASYNC_MAX_EXECUTION_TIMEOUT | float | 21600.0 | Maximum execution timeout in seconds (6 hours) |
AGENTFIELD_ASYNC_DEFAULT_EXECUTION_TIMEOUT | float | 7200.0 | Default execution timeout in seconds (2 hours) |
AGENTFIELD_ASYNC_POLLING_TIMEOUT | float | 20.0 | Timeout for individual poll requests (20s) |
Concurrency & Batching
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_ASYNC_MAX_CONCURRENT_EXECUTIONS | integer | 4096 | Maximum concurrent executions to track |
AGENTFIELD_ASYNC_MAX_ACTIVE_POLLS | integer | 512 | Maximum concurrent polling operations |
AGENTFIELD_ASYNC_CONNECTION_POOL_SIZE | integer | 64 | HTTP connection pool size for control plane API calls |
AGENTFIELD_ASYNC_BATCH_SIZE | integer | 100 | Maximum executions to check in single batch request |
Example: High-Performance Agent
AGENTFIELD_ASYNC_MAX_CONCURRENT_EXECUTIONS=8192
AGENTFIELD_ASYNC_CONNECTION_POOL_SIZE=128
AGENTFIELD_ASYNC_BATCH_SIZE=200See also: Async Execution Architecture, Performance Tuning
Feature Flags
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_ASYNC_ENABLE_ASYNC_EXECUTION | boolean | true | Master switch for async execution (disable to force sync mode) |
AGENTFIELD_ASYNC_ENABLE_BATCH_POLLING | boolean | true | Enable batch status checking (more efficient) |
AGENTFIELD_ASYNC_ENABLE_RESULT_CACHING | boolean | true | Cache execution results to reduce API calls |
AGENTFIELD_ASYNC_FALLBACK_TO_SYNC | boolean | true | Automatically retry as sync request if async fails |
AGENTFIELD_ASYNC_ENABLE_EVENT_STREAM | boolean | false | Use Server-Sent Events (SSE) for real-time updates (experimental) |
Example: Force Synchronous Mode (for debugging)
AGENTFIELD_ASYNC_ENABLE_ASYNC_EXECUTION=falseEvent Streaming (SSE)
Server-Sent Events provide real-time execution updates (experimental feature).
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_ASYNC_EVENT_STREAM_PATH | string | /api/ui/v1/executions/events | SSE endpoint path |
AGENTFIELD_ASYNC_EVENT_STREAM_RETRY_BACKOFF | float | 3.0 | Seconds to wait before reconnecting after stream error |
AGENTFIELD_ASYNC_COMPLETED_EXECUTION_RETENTION_SECONDS | float | 600.0 | How long to retain completed execution results (10 minutes) |
Uvicorn Web Server
Configure the Uvicorn ASGI server that runs Python agents.
| Variable | Type | Default | Description |
|---|---|---|---|
UVICORN_WORKERS | integer | 1 | Number of Uvicorn worker processes (for multi-core scaling) |
UVICORN_LOG_LEVEL | string | warning | Uvicorn log level: debug, info, warning, error, critical |
Multi-Core Production Setup
To utilize multiple CPU cores, increase worker count:
UVICORN_WORKERS=4 # Use 4 CPU coresRule of thumb: Set to (2 × CPU cores) + 1
Example: Production Configuration
UVICORN_WORKERS=4
UVICORN_LOG_LEVEL=infoPython SDK Logging
Control logging verbosity and behavior in the Python SDK.
| Variable | Type | Default | Description |
|---|---|---|---|
AGENTFIELD_LOG_LEVEL | string | WARNING | SDK log level: DEBUG, INFO, WARNING, ERROR, SILENT |
AGENTFIELD_LOG_TRUNCATE | integer | 200 | Maximum log message length before truncation |
AGENTFIELD_LOG_PAYLOADS | boolean | false | Show full request/response payloads in logs (very verbose) |
AGENTFIELD_LOG_TRACKING | boolean | false | Show execution tracking messages |
AGENTFIELD_LOG_FIRE | boolean | false | Show fire-and-forget workflow messages |
Example: Verbose Logging for Debugging
AGENTFIELD_LOG_LEVEL=DEBUG
AGENTFIELD_LOG_PAYLOADS=true
AGENTFIELD_LOG_TRACKING=trueExample: Production Logging (Quiet)
AGENTFIELD_LOG_LEVEL=INFO
AGENTFIELD_LOG_TRUNCATE=500See also: Python SDK Configuration
Go SDK Configuration
AI Integration
Configure AI/LLM providers for Go-based agents.
| Variable | Type | Default | Description |
|---|---|---|---|
OPENAI_API_KEY | string | — | OpenAI API key for GPT models |
OPENROUTER_API_KEY | string | — | OpenRouter API key (if set, auto-switches to OpenRouter) |
AI_BASE_URL | string | https://api.openai.com/v1 | Base URL for OpenAI-compatible API |
AI_MODEL | string | gpt-4o | Default LLM model name |
OpenRouter Support
If OPENROUTER_API_KEY is set, the Go SDK automatically uses OpenRouter instead of OpenAI, giving you access to models from Anthropic, Google, Meta, and more.
Example: Using OpenAI
OPENAI_API_KEY=sk-proj-...
AI_MODEL=gpt-4o-miniExample: Using OpenRouter
OPENROUTER_API_KEY=sk-or-v1-...
AI_MODEL=anthropic/claude-3-5-sonnet-20241022Example: Using Custom OpenAI-Compatible API
OPENAI_API_KEY=your-key
AI_BASE_URL=https://your-llm-api.com/v1
AI_MODEL=custom-modelSee also: Go SDK Overview, Go SDK Agent Package
Docker Deployment Variables
PostgreSQL Container
When running PostgreSQL in Docker (for development or simple deployments).
| Variable | Type | Default | Description |
|---|---|---|---|
POSTGRES_USER | string | agentfield | PostgreSQL superuser username |
POSTGRES_PASSWORD | string | agentfield | PostgreSQL superuser password |
POSTGRES_DB | string | agentfield | Default database name |
Example: Docker Compose
services:
postgres:
image: postgres:15
environment:
POSTGRES_USER: agentfield
POSTGRES_PASSWORD: secure_password
POSTGRES_DB: agentfieldSee also: Docker Deployment Guide
Quick Start Examples
1. Local Development (Minimal)
Control Plane:
AGENTFIELD_PORT=8080
AGENTFIELD_MODE=local
AGENTFIELD_STORAGE_MODE=localPython Agent:
OPENAI_API_KEY=sk-...
AGENTFIELD_LOG_LEVEL=INFO2. Production (PostgreSQL + Multiple Agents)
Control Plane:
AGENTFIELD_PORT=8080
AGENTFIELD_MODE=cloud
AGENTFIELD_STORAGE_MODE=postgres
AGENTFIELD_DATABASE_URL="postgres://user:pass@db.example.com:5432/agentfield?sslmode=require"
AGENTFIELD_STORAGE_POSTGRES_MAX_CONNECTIONS=100
AGENTFIELD_UI_ENABLED=true
AGENTFIELD_API_CORS_ALLOWED_ORIGINS=https://app.example.comPython Agent:
AGENT_CALLBACK_URL=http://agent-1.internal:8000
PORT=8000
UVICORN_WORKERS=4
AGENTFIELD_ASYNC_MAX_CONCURRENT_EXECUTIONS=2048
AGENTFIELD_LOG_LEVEL=INFO
OPENAI_API_KEY=sk-...3. Docker/Kubernetes Deployment
Control Plane:
AGENTFIELD_PORT=8080
AGENTFIELD_STORAGE_MODE=postgres
AGENTFIELD_DATABASE_URL="postgres://user:pass@postgres-service:5432/agentfield?sslmode=disable"Python Agent:
AGENT_CALLBACK_URL=http://my-agent-service:8000
PORT=8000
AGENTFIELD_LOG_LEVEL=INFO
OPENAI_API_KEY=sk-...See also: Quick Start Guide, Docker Guide, Production Best Practices
Important Notes
Boolean Values
- Python SDK: Use string values
"true"or"false" - Go/Control Plane: Use unquoted boolean
trueorfalse
# Python SDK
AGENTFIELD_ASYNC_ENABLE_ASYNC_EXECUTION=true
# Go/Control Plane
AGENTFIELD_UI_ENABLED=trueDuration Format
Use Go duration syntax for timeout and interval values:
30s= 30 seconds5m= 5 minutes1h30m= 1 hour 30 minutes2h= 2 hours
Connection String Aliases
These three variables are equivalent for PostgreSQL connection:
AGENTFIELD_DATABASE_URL(recommended)AGENTFIELD_POSTGRES_URLAGENTFIELD_STORAGE_POSTGRES_URL
Container Networking
Critical: Set AGENT_CALLBACK_URL in Containers
When running agents in Docker, Kubernetes, or any containerized environment, you MUST set AGENT_CALLBACK_URL to a network-accessible URL. The control plane cannot use localhost to reach containerized agents.
Common mistakes:
- ❌
http://localhost:8000(won't work in containers) - ❌ Omitting the variable (auto-discovery fails in containers)
- ✅
http://agent-service:8000(Docker Compose service name) - ✅
http://agent.namespace.svc.cluster.local:8000(Kubernetes)
See Docker Deployment Guide for detailed examples.
Related Documentation
- CLI Configuration - Control plane config file and CLI flags
- Python SDK Configuration - Programmatic configuration in Python
- Go SDK Overview - Go agent configuration
- Docker Deployment - Container-specific configurations
- Production Best Practices - Production deployment patterns
- Quick Start - Getting started guide