Skip to main content

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 the BaseEnvironment interface.

BaseEnvironment Interface

All environments implement the abstract BaseEnvironment class defined in src/harbor/environments/base.py:

Environment Types

Harbor supports several environment providers:

Docker (Local)

Default environment using local Docker:
Features:
  • Local execution
  • Full control over resources
  • Supports GPU (with nvidia-docker)
  • Can disable internet access
  • Mounts log directories

Daytona

Cloud execution via Daytona:
Features:
  • Cloud-based execution
  • Scalable parallel runs
  • Managed infrastructure
  • Network isolation options

E2B

E2B sandbox environment:
Features:
  • Secure sandboxing
  • Fast startup times
  • API-based access
Serverless cloud execution:
Features:
  • Serverless infrastructure
  • GPU support
  • Automatic scaling
  • Pay-per-use pricing

Runloop

Runloop environment:

GKE (Google Kubernetes Engine)

Kubernetes-based execution:
Features:
  • Kubernetes orchestration
  • Enterprise-grade reliability
  • Advanced resource management

ExecResult

Command execution returns an ExecResult object:
Example usage:

Resource Configuration

Environments are configured through EnvironmentConfig in task.toml:

EnvironmentConfig Model

Field Descriptions

  • build_timeout_sec: Maximum time to build the environment
  • docker_image: Pre-built image to use (skips Dockerfile build)
  • cpus: Number of CPU cores
  • memory_mb: Memory allocation in megabytes
  • storage_mb: Storage allocation in megabytes
  • gpus: Number of GPUs to allocate
  • gpu_types: Acceptable GPU types (e.g., ["H100", "A100", "T4"])
  • allow_internet: Whether to allow internet access
  • mcp_servers: MCP servers available in the environment
  • skills_dir: Path to skills directory

Resource Overrides

Override task resources at runtime:
Overriding resources may disqualify results from official leaderboards, as it changes the task specification.
The override system validates changes:

GPU Support

Not all environments support GPUs. Harbor validates GPU requirements:
GPU-capable environments:
  • Docker (with nvidia-docker)
  • Modal
  • GKE

Internet Access Control

Some benchmarks require isolated environments:
Harbor validates this capability:
Environments supporting internet control:
  • 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:
Default implementations use shell commands:

Mounted vs Non-Mounted

The is_mounted property determines how logs are handled:

Mounted Environments

Log directories are mounted from the host:
  • Docker (typically)
  • Local environments
Logs are immediately available on the host filesystem.

Non-Mounted Environments

Logs must be downloaded:
  • E2B
  • Modal
  • Cloud environments
Logs are retrieved via download_dir() after execution.

Environment Lifecycle

Typical Workflow

Creating Custom Environments

Step 1: Implement BaseEnvironment

Step 2: Register Environment Type

Add to src/harbor/models/environment_type.py:

Step 3: Update Factory

Register in src/harbor/environments/factory.py:

Best Practices

  • Allocate resources based on actual task needs
  • Don’t over-provision (increases costs)
  • Don’t under-provision (causes failures)
  • Test with minimal resources first
  • Disable internet when possible for reproducibility
  • Document when internet access is required
  • Use allow-lists for specific endpoints
  • Consider offline alternatives
  • Always clean up environments (use try/finally)
  • Handle timeout errors gracefully
  • Log environment setup failures
  • Provide actionable error messages
  • Cache built images when possible
  • Use pre-built images for common setups
  • Minimize upload/download operations
  • Optimize Dockerfiles for build speed

Tasks

Task structure and configuration

Agents

Agents that execute in environments

Trials

Trial execution workflow

Verifiers

Verification in environments