Skip to main content
The AI SDK harness runs coding agents such as Claude Code, Codex, and OpenCode through the AI SDK’s HarnessAgent. @archildata/ai-sdk-harness provides the sandbox they run in: an Archil sandbox with private ports, egress policy, credentials added outside the sandbox, and reusable templates. It works with any harness adapter.

Setup

Set ARCHIL_API_KEY and ARCHIL_REGION, or pass an Archil client as client. Then install the adapter for your agent, such as @ai-sdk/harness-claude-code, and set its model credentials, such as ANTHROPIC_API_KEY or AI_GATEWAY_API_KEY.

Run Claude Code

Options

createArchilNetworkSandboxSession takes any sandboxes.create setting, such as baseImage, vcpuCount, memSizeMiB, env, or mounts, plus these: Sandboxes get IS_SANDBOX=1 in their environment, which lets Claude Code run as the sandbox’s root user.

Ports

Ports stay private. The harness reaches each port through a port token that Archil’s proxy checks, so nothing in the sandbox is exposed publicly.

Network policy and credentials

The harness sets the sandbox’s egress policy and adds model credentials to outbound requests through Archil’s firewall. The sandbox holds only a placeholder key, and Archil adds the real key to requests to the model provider’s host. On the Free plan, the sandbox keeps Archil’s managed egress allowlist, and adapters pass credentials into the sandbox instead.

Templates

With a template, the adapter’s setup runs once: Archil prepares a template sandbox, stops it, and forks each new session from it. Later sessions with the same settings start from the prepared sandbox, across processes and machines. The template sandbox stays in your account so sessions can fork from it; delete it when you no longer need it.

Lifecycle

stop() pauses the sandbox, keeping its memory and processes. destroy() deletes it.

Resume

To reattach to a sandbox from another process, stop it instead of destroying it, then resume it by its name, the session’s id:
Pass the same ports you created the session with.