Skip to main content
Fast startup times enable humans and agents to work effectively and autonomously across multiple tasks in parallel. Optimized environments typically start in 1-3 minutes; without optimization, startup can take 10+ minutes.

Why this matters

Humans and agents work best with ephemeral environments - one environment per task, treated like cattle not pets. This isolation means:
  • No state conflicts: Each task gets a clean slate
  • Parallel execution: Multiple agents work simultaneously without interference
  • Mistakes are free: If something goes wrong, discard the environment and start fresh - no damage to your local machine or endpoint
But ephemeral only works if environments start reasonably fast. A 10-minute startup kills productivity. A 2-minute startup enables effective parallel work.

Optimization strategies

Use prebuilds

Prebuilds run your environment setup ahead of time - container builds, dependency installation, and startup tasks. When an agent starts an environment, it loads from a prebuild snapshot instead of running setup from scratch. This is the single biggest optimization for agent workflows. Configure prebuilds to run on pushes to main and your environments will be ready when agents need them.

Enable Dev Container image caching

For runners in your VPC, enable image caching to avoid rebuilding containers:
  • AWS runners: Caches built Dev Container images automatically
  • GCP runners: Supports image caching through Artifact Registry
Ona Cloud includes image caching by default.

Optimize your Dockerfile

Structure your Dockerfile for caching efficiency:
  • Put stable dependencies first: System packages, build tools, and runtimes that rarely change should be early in the Dockerfile
  • Put volatile dependencies last: Application dependencies that change frequently go at the end
  • Use prebuilt base images: Push your base image to a registry and reference it in devcontainer.json

Use tasks for dynamic setup

For setup that must happen at runtime (database seeding, environment-specific config), use Tasks rather than baking everything into the image.

One environment per task

Rather than reusing environments across tasks, create a fresh environment for each piece of work. This matches how agents operate most effectively:
  1. Agent receives a task
  2. Agent starts a clean environment
  3. Agent completes the work and creates a PR
  4. Environment is discarded
With proper optimization, this workflow keeps startup times manageable. The isolation benefits far outweigh the startup cost.

Measuring startup time

Track your environment startup times to identify bottlenecks:
  • Container build time: How long to build the Dev Container image?
  • Dependency installation: How long do tasks take to run?
  • Prebuild freshness: Are prebuilds running often enough?
If agents are waiting more than a couple of minutes for environments, investigate your prebuild configuration first.