---
title: "Boxes"
description: "What a box is, how it is created, opened, stopped and removed, and how abx decides which box a command means."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/agent-box/llms.txt
> Use this file to discover all available pages before exploring further.

# Boxes

A box is one smolvm microVM with its own disk, network policy and credential bindings, tied to a [workspace](https://sandrinodm.github.io/agent-box/concepts/workspaces/). This page covers its lifecycle and how commands pick a box. Read it before you script abx or remove a box you care about.

## Lifecycle

![Box lifecycle. Launching an agent creates a box that is Running. abx stop moves it to Stopped, which keeps the disk, and launching again returns it to Running. abx rm moves a stopped box to Archived: the machine is deleted and the box record and transcripts go to the workspace archive.](https://sandrinodm.github.io/agent-box/_nimbus/md/1bmxyxo/box-lifecycle.webp)

1. **Create.** The first launch of a name creates the box: abx creates its directory under `$ABX_HOME/workspaces/`, writes `box.json`, creates the machine from the active [image](https://sandrinodm.github.io/agent-box/concepts/images/), and checks that `/work` is empty. In a Git workspace it then imports the base commit and creates the branch `agent/<box>`. A creation that was interrupted resumes on the next launch.
2. **Open.** Every launch first compares what smolvm reports for the machine (labels, network settings, credential bindings, mounts) with what abx recorded in `box.json`. A mismatch stops the launch with `policy-mismatch`.
3. **Launch.** abx resolves credentials on the host just before the VM starts and runs the agent or shell in a [session](https://sandrinodm.github.io/agent-box/concepts/sessions/).
4. **Stop.** `abx stop` stops the machine and keeps its disk.
5. **Remove.** `abx rm` deletes the machine and moves the box record to the workspace archive.

A box is live while its `box.json` exists.

## Naming

Names match `[a-z0-9][a-z0-9-]{0,39}`. In a Git checkout a new box without a name is named after the current branch, lowercased with other characters replaced by `-`, unless that gives `main` or `master`. Otherwise, and in a scratch folder, it is named `task-<8 hex>`. Naming a box like a command, alias or agent prints a warning.

## Choosing a box

`abx help --json` carries the authoritative rule in its `boxSelection` field. It starts:

> Use an explicit box name in automation. Without one, a launch reopens the only box in the current scope, fails and lists the names when several exist, or creates a box when none exist. Other commands fail when the scope has no box.

In practice:

| Situation | Launch (`abx <agent>`, `abx shell`) | Other commands (`stop`, `diff`, `land`, ...) |
| --- | --- | --- |
| One box in scope | Reopens it. | Uses it. |
| Several boxes | Fails with `ambiguous-box` and lists the names. | Fails with `ambiguous-box`. |
| No box | Creates one. | Fails with `no-box`. |

"Scope" is the workspace of the current folder. Git boxes share the scope of the repository, and scratch boxes belong to the exact current directory. Use `-C DIR` to address the boxes of another directory, or `abx ls --all` to list every workspace.

> **Name the box in scripts**
>
> Pass the box name and `--no-create`, so a typo fails with `no-box` instead of creating a new box. `ABX_JSON=1` makes `--no-create` the default. See [Headless runs](https://sandrinodm.github.io/agent-box/automation/headless/).

## What is fixed at creation

The network policy, the granted agents, the credential access route and account connectors are set when the box is created. The creation options (`--net`, `--allow`, `--agents`, `--access`, `--auth-profile`, `--connectors`, `--no-connectors`) are still accepted when you reopen an existing box, as long as they match what the box recorded. That lets one command both create and reopen a box. A different value fails with `fixed-option`. `--allow` hosts only need to be among the box's allowed hosts.

To see the recorded values, run `abx ls <box> --json`. To see the network, run `abx net <box>`. See [Network policy](https://sandrinodm.github.io/agent-box/network/policy/).

## Disks and what survives

Each box has its own disk. Files in `/work` and in the guest user's home directory, including agent state and a `local` login, live on it and survive `stop` and later launches. Nothing is shared with other boxes, and nothing is copied out of the box automatically: work leaves a Git box only through [`abx diff` and `abx land`](https://sandrinodm.github.io/agent-box/git-workflow/review-and-land/). A scratch box starts with an empty `/work` and receives no files from your host.

The one host directory a box mounts is its `transcripts/` directory, at `/abx/transcripts`. See [Sessions](https://sandrinodm.github.io/agent-box/concepts/sessions/#transcripts).

## Stop versus remove

| | `abx stop` | `abx rm` |
| --- | --- | --- |
| Machine | Stopped. | Deleted. |
| Disk and `/work` | Kept. | Deleted. |
| Staging repository (Git boxes) | Kept. | Deleted. |
| Box record and transcripts | Stay in place. | Moved to the workspace `archive/`. |
| Can be repeated | Yes. Stopping a stopped box succeeds. | Yes, with `--if-exists`. |

`abx stop [box | --all]` (or `abx stop [box] --workspace WORKSPACE` for an unlinked workspace) verifies the box's network policy and checks for active guest processes first. A detached [session](https://sandrinodm.github.io/agent-box/concepts/sessions/) counts as active, so exit the agent or shell before you stop the box, or `stop` fails with `box-busy`. `--force` stops a box with active processes, ending its sessions, or one whose policy cannot be verified. Unflushed guest writes can be lost. `--all` stops every managed box across all workspaces.

`abx rm <box>...` (or `abx rm <box>... --workspace WORKSPACE` for an unlinked workspace) refuses, without `--force`:

- a running box (`box-running`; stop it first),
- a Git box whose branch holds commits that were not in its base and were never landed with `abx land` (`unlanded-commits`; checking a stopped Git box starts it briefly and stops it again),
- a box whose machine is missing (`machine-missing`), because its commits cannot be checked.

`rm` does not check uncommitted guest changes or the files of a scratch box. `--force` stops a running box, skips the commit check, and also archives a box whose machine is missing, unless that box holds a shared guest login profile. More detail is on [Removing boxes](https://sandrinodm.github.io/agent-box/git-workflow/removing-boxes/).

## The archive

`rm` moves the box directory, with its `box.json` and agent transcripts, from `boxes/<box>-<id8>/` to `archive/<box>-<id8>/` in the workspace directory under `$ABX_HOME/workspaces`, and prints the path of the archived `transcripts/`. It never deletes transcripts. A later box with the same name gets a new directory. The archive is untrusted guest output like any other `transcripts/` directory, so read it without following symlinks.

```text
$ABX_HOME/workspaces/<name>-<id8>/
  workspace.json
  boxes/<box>-<id8>/
    box.json
    staging.git/
    transcripts/
  archive/<box>-<id8>/
    box.json
    transcripts/
```

The full layout of `$ABX_HOME` is in [Files on the host](https://sandrinodm.github.io/agent-box/reference/files/).

Source: https://sandrinodm.github.io/agent-box/concepts/boxes/index.mdx
