Overview
Environments are containerized workspaces where agents execute tasks. They provide isolated, reproducible execution contexts with controlled resources, dependencies, and network access. Harbor supports multiple environment providers, from local Docker to cloud platforms like Modal and Daytona, all unified under theBaseEnvironment interface.
BaseEnvironment Interface
All environments implement the abstractBaseEnvironment class defined in src/harbor/environments/base.py:
Environment Types
Harbor supports several environment providers:Docker (Local)
Default environment using local Docker:- Local execution
- Full control over resources
- Supports GPU (with nvidia-docker)
- Can disable internet access
- Mounts log directories
Daytona
Cloud execution via Daytona:- Cloud-based execution
- Scalable parallel runs
- Managed infrastructure
- Network isolation options
E2B
E2B sandbox environment:- Secure sandboxing
- Fast startup times
- API-based access
Modal
Serverless cloud execution:- Serverless infrastructure
- GPU support
- Automatic scaling
- Pay-per-use pricing
Runloop
Runloop environment:GKE (Google Kubernetes Engine)
Kubernetes-based execution:- Kubernetes orchestration
- Enterprise-grade reliability
- Advanced resource management
ExecResult
Command execution returns anExecResult object:
Resource Configuration
Environments are configured throughEnvironmentConfig in task.toml:
EnvironmentConfig Model
Field Descriptions
build_timeout_sec: Maximum time to build the environmentdocker_image: Pre-built image to use (skips Dockerfile build)cpus: Number of CPU coresmemory_mb: Memory allocation in megabytesstorage_mb: Storage allocation in megabytesgpus: Number of GPUs to allocategpu_types: Acceptable GPU types (e.g.,["H100", "A100", "T4"])allow_internet: Whether to allow internet accessmcp_servers: MCP servers available in the environmentskills_dir: Path to skills directory
Resource Overrides
Override task resources at runtime:GPU Support
Not all environments support GPUs. Harbor validates GPU requirements:- Docker (with nvidia-docker)
- Modal
- GKE
Internet Access Control
Some benchmarks require isolated environments:- Docker
- Some cloud providers (check documentation)
File Operations
Upload Files
Copy local files to the environment:Download Files
Retrieve files from the environment:Command Execution
Basic Execution
With Working Directory
With Environment Variables
With Timeout
Filesystem Utilities
Check paths in the environment:Mounted vs Non-Mounted
Theis_mounted property determines how logs are handled:
Mounted Environments
Log directories are mounted from the host:- Docker (typically)
- Local environments
Non-Mounted Environments
Logs must be downloaded:- E2B
- Modal
- Cloud environments
download_dir() after execution.
Environment Lifecycle
Typical Workflow
Creating Custom Environments
Step 1: Implement BaseEnvironment
Step 2: Register Environment Type
Add tosrc/harbor/models/environment_type.py:
Step 3: Update Factory
Register insrc/harbor/environments/factory.py:
Best Practices
Resource Allocation
Resource Allocation
- Allocate resources based on actual task needs
- Don’t over-provision (increases costs)
- Don’t under-provision (causes failures)
- Test with minimal resources first
Network Access
Network Access
- Disable internet when possible for reproducibility
- Document when internet access is required
- Use allow-lists for specific endpoints
- Consider offline alternatives
Error Handling
Error Handling
- Always clean up environments (use try/finally)
- Handle timeout errors gracefully
- Log environment setup failures
- Provide actionable error messages
Performance
Performance
- Cache built images when possible
- Use pre-built images for common setups
- Minimize upload/download operations
- Optimize Dockerfiles for build speed
Related Topics
Tasks
Task structure and configuration
Agents
Agents that execute in environments
Trials
Trial execution workflow
Verifiers
Verification in environments