Environments

Independent target management and portable execution across local, container, cloud, and remote backends.

a13n-harness provides files, commands, processes, output, and ports without requiring an Agent or a model. Service owns managed target creation, stop, renewal, and destruction. Applications can use it directly or pass an EnvironmentConnector to Harness, which opens an independent execution for each Run. Optional SDKs belong to this package's docker, e2b, and modal extras.

Start here

TaskGuide
Read and write a file with no network dependenciesGetting started
Choose local, sandbox, container, or remote executionChoose a backend
Understand close, state, re-entry, and destructionLifecycle and state
Configure built-ins, credentials, and runtime collaboratorsProvider configuration
Compare the six cloud ProvidersCloud Providers
Implement a Provider or supply Host runtimesProviders and runtime
Run commands, inspect processes, and read retained outputCommands and processes
Understand paths, search patterns, and output limitsOperations
Run a complete built-in lifecycleRunnable examples
Connect HTTP or reverse WebSocket EnvdRemote Envd
Expose Environment tools to an AgentHarness integration

Choose a backend

Use no Environment when the Agent needs only ordinary tools or remote APIs. Otherwise select a Native or Envd route:

RouteProviderUse it forOperation and ownership boundary
Nativedirect_localTrusted local automationHost OS operations; existing directory, no sandbox claim
Nativee2bNative managed cloud sandboxE2B SDK; sandbox create/pause/resume/renew/destroy
NativedaytonaCloud sandboxNative stop/start and preserved files
NativemodalCloud sandboxSnapshot-backed stop/resume; fixed running lifetime
NativevercelCloud sandboxNamed persistent sandbox with native sessions
NativespritesCloud sandboxPersistent disk and automatic sleep/wake
NativerunloopCloud sandboxDevbox suspend/resume and idle keepalive
Envdlocal_envdCLI and local AgentsPrivate stdio daemon; close preserves files
NativedockerSingle-host servicesDocker Engine lifecycle and exec; close preserves container
Envdhttp_envdNetwork-reachable external daemonsHTTP(S) EIP; connect-only
Envdwebsocket_envdDaemons that connect back to a HostReverse WebSocket EIP; Host-integrated SDK, connect-only

Try the remote examples locally without a model, Docker or cloud account.

Management, connection, and execution

The Host explicitly manages targets through EnvironmentProvider and saves EnvironmentState. An EnvironmentConnector describes one fixed target with no construction-time I/O; each open() returns a new, ready EnvironmentExecution.

Executions expose operations and have distinct execution_id values. Closing an execution releases its resources without destroying the target. Readiness never creates, starts, replaces, or renews a target. Later reconnection requires an explicit new execution.

Use with Harness

The working directory must already exist:

Use the Host-owned PreparedSource implementation from the Harness environment guide. It returns the prepared connector on first use.

Python
from pathlib import Path
from a13n_harness.providers.environment.direct_local.provider import DIRECT_LOCAL

connector = DIRECT_LOCAL.execution_connector(
    {"root": {"path": str(Path("./workspace").resolve())}},
    environment_id="env-workspace",
)
result = await executable.run("Inspect the workspace", environment=PreparedSource(connector))

Harness validates and publishes the static mount set without opening executions. First use prepares and opens only the selected mount. Each used mount has its own execution; Run exit closes these executions without destroying targets.

Enable DynamicEnvironmentCapability to expose permitted tools to the model. Use EnvironmentMount for mount paths and permission ceilings; Harness owns these policies, and they do not enter shared Environment state.

Use Local Envd

Local Envd requires a borrowed LocalEnvdProviderRuntime. The Host chooses a compatible executable and private-runtime allocator. Each execution opens an independent EIP Session, while the Host closes the shared Device. See Providers and runtime.

Direct Local uses the Host account without OS isolation. For Local Envd, the Host selects sandbox and network policy at launch, and Envd enforces it for each Session. Remote HTTP and WebSocket Envd connect only to registered devices; see Remote Envd.

Retain targets and manage state

Create or start a target explicitly, publish the result under Host concurrency control, then generate a connector. Execution produces no new management state to write back after a Run. Stop, renewal, and destruction are explicit Host actions; see Lifecycle and state.

Service builds templates, managed instances, and Run mounts on this library; see Service environments. For more embedding patterns, see Harness environments.

On this page