Environments

Unified execution runtime for reading files, executing shell commands, and driving computer automation across local paths, containers, and cloud sandboxes.

Environments provides a portable execution interface for filesystems, OS processes, and desktop GUI operations. Your application or Agent uses the exact same API whether working in a local directory, a Docker container, or a cloud microVM.

Environments ships inside a13n-harness and can also be used directly as a standalone Python library without an LLM.

Start here

Follow the Environment quickstart to open a workspace, write and read a file, and release resources cleanly, then continue by task:

TaskGuide
Select an execution targetChoose a backend (Local, Docker, E2B, cloud sandboxes)
Configure runtime credentials & optionsProvider configuration
Execute commands & inspect streamsCommands and processes
File inspection, search & bounded readsOperations
Manage target lifecycles & reconnectLifecycle and state
Connect an existing daemon over EIPRemote Envd
Expose execution to agents as toolsHarness integration

Choose a backend

Environments offers two execution pathways:

  • Native execution: Uses backend-native file and shell APIs (direct_local, docker, e2b, vercel, sprites, runloop, boxd).
  • Envd execution: Connects over the Environment Interaction Protocol (EIP) to a13n-envd—unlocking OS sandboxing, controlled network egress, desktop Computer Use, and live telemetry.
ProviderExecution typeBackend mechanism
direct_localNativeAccesses an existing local path under the Host process identity
local_envdEnvdConnects to a Host-spawned native a13n-envd daemon over stdio
dockerNative / EnvdExecutes inside a managed Docker container
e2bNative / EnvdRuns inside an isolated E2B cloud sandbox
daytonaEnvdRuns inside a Daytona cloud sandbox
modalEnvdRuns inside a serverless Modal sandbox
vercelNative / EnvdRuns inside a Vercel Sandbox
spritesNative / EnvdRuns inside a Fly.io Sprite
runloopNativeRuns inside a Runloop Devbox
boxdNativeRuns inside an isolated boxd VM
http_envdEnvdConnects to an existing remote Envd daemon over HTTP(S)
websocket_envdEnvdConnects to an Envd daemon reverse-tunneled over WebSocket

Management, connection, and execution

  1. Prepare the target: The Host creates a directory, container, or cloud sandbox (or selects a registered Device).
  2. Build a connector: EnvironmentConnector describes a fixed target without performing network I/O.
  3. Open an execution: await connector.open() returns an active EnvironmentExecution handle; closing it releases execution resources while preserving the target.

Use with Harness

Supply an EnvironmentSource (returning an EnvironmentConnector from ensure_ready(), see Supply a source), optionally restrict paths with EnvironmentMount, and attach DynamicEnvironmentCapability on HarnessBuilder:

Python
from a13n_harness import AgentSpec, HarnessBuilder
from a13n_harness.environment import DynamicEnvironmentCapability, DynamicEnvironmentConfiguration

executable = HarnessBuilder().build(
    AgentSpec(),
    output_type=str,
    model=model,
    capabilities=(
        DynamicEnvironmentCapability(
            DynamicEnvironmentConfiguration(files_enabled=True, shell_enabled=True)
        ),
    ),
)
# Pass environment=source when calling await executable.run("...", environment=source)

Use Local Envd

Construct a Host-owned LocalEnvdProviderRuntime when running local workloads with native OS isolation, controlled egress, or desktop Computer Use (see Providers and runtime):

Python
from a13n_harness.providers.environment.local_envd.runtime import (
    LocalEnvdProviderRuntime,
    TemporaryLocalEnvdRuntimeAllocator,
    resolve_a13n_envd_executable,
)

runtime = LocalEnvdProviderRuntime(
    executable=resolve_a13n_envd_executable(),
    allocate_private_runtime=TemporaryLocalEnvdRuntimeAllocator(),
)

Retain targets and manage state

Persist the provider's returned EnvironmentState under your Host's concurrency control after creation or start, rebuild connectors from that saved state on later Runs, and stop or destroy the target explicitly when the session ends. See Service environments for managed templates and lifecycle orchestration.

On this page