---
url: /reference/vm.md
---
# MicroVM backend

The details of runs on the microVM backend (`--backend vm`): what they require, their limits, and their errors. [Running in a microVM](/run/vm.md) shows how to use it. The options are in the [command line](/reference/cli.md), the `[vm]` and `[policy]` keys in [`config.toml`](/reference/config-toml.md), and every error code in [exit codes and errors](/reference/errors.md).

## Requirements

* macOS 13 or later on Apple Silicon. Elsewhere a VM run fails before anything starts with `backend_unsupported`, and never falls back to the host.
* A Pandra binary signed with the virtualization entitlement. A release is signed. A binary built from a checkout fails with `vm_entitlement_missing`; sign it with `cargo xtask sign`, run in the checkout.

## Backend

* `--backend host|vm` on `pandra run` and `pandra sync` selects the backend. Without it, `backend` in the agent's table applies, then `backend` in `[defaults]`, and the default is `host`. A package cannot choose its backend.
* A session keeps the backend it was created on. `pandra resume` takes no `--backend`.
* On the host backend, `--network-preset`, `--allow-host`, and `--publish` are a usage error, and the `policy` and `vm` tables have no effect. When a `policy` table sets a preset or a destination for the agent, the approval summary adds a `Policy:` row and a host dry run a `Policy` row: `not enforced on the host backend; --backend vm enforces it`.

## Resources

| Resource | Default | Set with |
|---|---|---|
| CPUs | 4, or all of the Mac's when it has fewer | `--cpus N`, `cpus` in the `vm` tables |
| Memory | the smaller of 4 GiB and half of the Mac's | `--memory SIZE`, `memory` in the `vm` tables, such as `"8GiB"` |

* `--cpus` and `--memory` work on `run` and `resume`. A value the Mac cannot give fails with a usage error that names the range.
* The CPUs and memory are limits, not reserved when the VM starts. A VM takes memory from the Mac as its guest uses it, and keeps what it took until its run ends.

## Downloads

* The first VM run downloads what the VM needs and keeps it. `pandra sync AGENT --backend vm` downloads it ahead.
* With `--offline`, a VM run that misses a part fails with `vm_asset_missing`, which lists each part and names the `pandra sync` command above.
* The VM runs the harness version that `--harness-version` or the configuration pins, else the version of the harness on your Mac. Without either, the run fails with `harness_not_found`, and the fix is `pandra harness use NAME@VERSION`. A `path` set for the harness is not used in the VM.
* Under `[harnesses] downloads = "manual"`, Pandra never downloads the harness's Linux build. Install it with `pandra harness install NAME@VERSION --platform linux-arm64`. `pandra harness list` shows Linux installations with `linux-arm64` in its `PLATFORM` column, and `pandra harness remove NAME@VERSION --platform linux-arm64` removes one.
* A download whose digest differs is not kept, and the run fails with `digest_mismatch`.

## Images

* The default image is `ghcr.io/pandra-io/vm-base`: Debian with git, ripgrep, curl, less, Node, uv with Python, the GitHub CLI, bubblewrap, socat, the OpenSSH server, and CA certificates. Its user `agent` can use `sudo` without a password.
* `image` in the `vm` tables names another image, by tag or digest. Pandra pulls its `linux/arm64` variant with the credentials `pandra pull` uses. A registry on a loopback address, such as `localhost:5001`, is reached over plain HTTP, and every other one over HTTPS.
* An image must be built `FROM` the base image and keep its OpenSSH server, socat, and the `agent` account. An image not built from the base, or without a `linux/arm64` variant, fails with `vm_image_unsupported`. An image that removes either program or locks `agent` fails with `vm_start_failed`.
* The image's environment variables are used. Its entrypoint, command, user, and working directory are not.
* `[runners]` is not used in a VM.
* An MCP server distributed as an OCI image cannot run in a VM, which has no container runtime: the run fails with `vm_server_unsupported`.

## Session disks

* Each session has a disk of its own, made from its image, which holds everything outside the shared directories. `pandra resume` boots the same disk, so what the agent installed is still there. A newer image applies to new sessions only.
* The sessions that one TUI run creates share that run's VM and its disk.
* A disk is used by one run at a time. A run of a session whose disk another run uses fails with `vm_disk_busy`, which names that session: wait for it to end, or stop it.
* A disk takes only the space the agent wrote.
* A disk is removed with the last session that uses it. `pandra system prune` also removes the disks, images, and other VM downloads that nothing uses, and counts them as VM parts (`Removed 3 VM parts`, and `vm_parts` with `--json`).

## Files, environment variables, and commands

* The VM shares the run's workspace and the session's harness home for reading and writing, and the run's prepared files and the harness's installation for reading only, each at its path on the Mac. A run in a worktree also shares its repository's Git directory, for reading and writing.
* A workspace, or a worktree's Git directory, that is or holds Pandra's data, configuration, or cache directory fails with `vm_workspace_too_broad`. The fix is a narrower workspace (`--workspace DIR`).
* A change made on the Mac is not reported to file watchers in the VM.
* The VM does not inherit your environment variables. It gets the image's variables, the ones the configuration sets for the agent, the ones `--env` passes, and the ones the harness needs.
* In the VM, only `pandra skill` and `pandra version` work. Every other command fails with `not_available_in_vm`, so an agent in the VM cannot start other agents through Pandra. The harness's own subagents work.

### `--env`

* `--env NAME=VALUE` and `--env NAME` (repeatable) on `run` and `resume` pass a variable into the VM. `NAME` alone takes the value your shell has when the run starts, and a name your shell does not set is not passed. When a name is given more than once, the last one applies.
* They apply over the configuration's `env`, and only to the run they are given to: a resume passes only its own.
* A name Pandra reserves is refused with `env_reserved`: a `PANDRA_*` name, a name Pandra removes from a run, a name the harness sets, a certificate variable such as `SSL_CERT_FILE` or `NODE_EXTRA_CA_CERTS`, and the harness's credential variables, which belong to a target.
* On the host backend, `--env` is a usage error: a host run inherits your shell's variables.
* A value given on the command line is never shown or written to a record. `--dry-run` lists the variable with the origin `--env` and no value, and a command Pandra suggests writes it as `--env NAME`.

## Network rules

| Preset | Allows |
|---|---|
| `strict` | Only the model and login endpoints. |
| `minimal`, the default | The model and login endpoints of the harness and provider, the remote MCP servers the package declares, and the registries of its servers' runners (`registry.npmjs.org` for `npx`, `pypi.org` and `files.pythonhosted.org` for `uvx`). |
| `balanced` | `minimal`, plus package registries, the base image's operating system mirrors, and code hosts. `--dry-run` lists them. |
| `open` | Every destination except the Mac's loopback and local network. |

* `network-preset` in the `policy` tables and `--network-preset` select the preset. `allow-hosts` in the `policy` tables and `--allow-host` add destinations. A run's destinations are those of the preset, `[policy]`, the agent's `policy` table, the flags, and the session's approvals together.
* The rules are read again at every resume.
* A destination is `HOST[:PORT]`, a host name or an IP address. The port is 443 when it is left out.
* `*.example.com` matches every subdomain of `example.com` at any depth, and not `example.com` itself. A lone `*`, a wildcard over one label such as `*.com`, and a wildcard in any label but the first are refused. `*.co.uk` is accepted.
* A run adds at most 1,024 destinations through the `policy` tables, `--allow-host`, and the hosts of its tokens together, and publishes at most 256 ports. More of either fails with `value_invalid`.
* The Mac's loopback, local network, and own addresses are refused under every preset, also when an allowed name resolves to one. `--allow-host 10.0.0.5:8080` allows that address. `--allow-host localhost:5432` makes the Mac's `127.0.0.1:5432` reachable as `host.pandra.internal:5432`.
* A name that is not allowed does not resolve, and a connection that is not allowed is reset.
* On port 443, and on the port of each host Pandra injects a credential for, the TLS server name must be allowed too. A connection there that is not TLS, or sends no server name, is refused.
* UDP other than name lookups is dropped. The VM has IPv4 only.
* A target whose base URL variable, such as `ANTHROPIC_BASE_URL`, takes its value from a secret cannot run in a VM: the run fails with `not_supported_yet`. Write the base URL as a literal.

## Refused destinations

* Each refused destination is reported once per run, and the end of a run lists them with the command that allows each.
* With `--json`, each is a `warning` event with the code `destination_refused` and the details `host`, `port`, and `allow_command`. `port` is null for a name refused when it was looked up. `allow_command` is null when allowing the destination would not help, such as a connection on port 443 that is not TLS.
* A run reports at most 1,000 destinations and counts the rest, as `refused_beyond_limit` in the `result` event with `--json`.

## `pandra policy`

```text
pandra policy list SESSION
pandra policy allow host SESSION HOST[:PORT]... [--save]
pandra policy remove host SESSION HOST[:PORT]...
pandra policy network-preset SESSION PRESET
```

* `list` shows the session's preset, each allowed destination with where it comes from, and the destinations its run has refused so far. For a session that is not running, it shows what a resume would start with.
* `allow host` allows destinations at once for the running VM and for the session's later resumes, and for the other sessions that share its disk. A destination is written as for `--allow-host`. What is allowed is what you write: `api.example.com` does not allow `*.example.com`. `--save` also writes the destinations to the agent's `policy` table.
* `remove host` takes back destinations the session approved, at once for the running VM and for later resumes, and prints `removed HOST:PORT` for each. A destination matches as written, so removing `api.example.com` leaves `*.example.com` approved. A destination the session did not approve, such as one a preset, a `policy` table, `--allow-host`, or a token allows, fails the command with a usage error, and nothing is removed. It has no `--save`: remove a saved destination from the agent's `policy` table. It cannot recall what already left the VM, and connections already open stay open.
* `network-preset` changes the session's preset. While its run goes on, a preset can only be widened, in the order `strict`, `minimal`, `balanced`, `open`.
* A session keeps at most 1,000 approved destinations. One more is a usage error; use a wildcard or `pandra policy network-preset` instead.
* Allowing a destination never sends a credential to it.
* `pandra policy` fails inside the VM. On the Mac, `allow`, `remove`, and `network-preset` fail when `PANDRA_RUN_ID` is set, as it is in an agent's run, and say that the user has to run them. An agent on the host runs as you and can unset the variable, so only the refusal inside the VM is a boundary. A session on the host backend has no policy, and the commands fail with a usage error.
* In an ACP session, the editor is asked with a permission request for a refused destination where allowing it can help, and allowing it allows the name on port 443 or on the port that was refused. A destination refused because it is a local address is only reported.

## Published ports

* `--publish [HOST_PORT:]GUEST_PORT` (`-p`, repeatable) on `run` and `resume`, and `ports` in the `vm` tables, publish a port of the VM on the Mac's `127.0.0.1`. The host port is the guest port when it is left out.
* A server in the VM must listen on `0.0.0.0` to be reachable.
* A host port that cannot be bound fails the run with `vm_port_in_use` before anything starts, and the run never uses another port. When `--publish` gave the port, the error's step is the same command with another host port. When the configuration gave it, the message names the file and line.

## Credentials

| Credential | In the VM |
|---|---|
| A target's credential | a placeholder; Pandra injects the value on requests to the provider |
| A secret header of a remote MCP server | a placeholder; injected on requests to the server |
| The harness's login on your Mac | a placeholder; injected on requests to the provider |
| A token for named hosts | a placeholder; injected on requests to the named hosts |
| A value for a local MCP server, a variable in `env` or passed with `--env` | the value itself |

* `[harnesses.NAME] secret-proxy = false` makes that harness's target credentials and the secret headers of its remote MCP servers enter the VM as values.
* The dry run's `Credentials` section says whether each credential is injected on the host or enters the VM.
* A placeholder sent to another host on a connection Pandra decrypts is passed on as it is, with a warning.
* A WebSocket to a host whose credential Pandra injects fails, so Claude Code's voice mode does not work in a VM.

### Logins

* Without a target credential, a VM run uses the harness's login on your Mac. Pandra never renews it and never gives the refresh token to the VM.
* An expired login fails the run with `vm_login_expired`: start the harness on your Mac once, which renews it. A Pi run renews Pi's login first through `pi auth print-bearer-token`. A token that expires during a run is read again when the provider rejects it, and the run stops with `vm_login_expired` when it was not renewed.
* For Claude Code's login, macOS can ask whether `security` may use the keychain item `Claude Code-credentials`. Allow it, or the run cannot use the login.
* These logins fail with `vm_login_unsupported`, and the fix is a target with an API key:
  * Claude Code's `apiKeyHelper`, or a credential variable in its settings' `env`.
  * Codex's `CODEX_API_KEY` in your shell, or a model provider in Codex's own configuration.
  * A Pi `models.json` that configures the run's provider.
  * Pi's ChatGPT login (the provider `openai-codex`).
* A Codex login kept in the macOS keyring cannot be shared with a run on either backend.

### Tokens for named hosts

* `[vm.tokens.NAME]` gives a token to every VM run, and `[agents."<identity>".vm.tokens.NAME]` to one agent. `secret` names a logical secret, `hosts` the hosts, and `env`, which is optional, a variable in the VM that holds the placeholder.
* The token's hosts are allowed destinations on port 443, and count toward the 1,024 destinations of a run.
* Git in the VM offers the token to those hosts and uses HTTPS for their SSH remotes, so a workspace cloned over SSH fetches and pushes unchanged.
* Your Git `user.name` and `user.email` are copied into the VM. SSH remotes of other hosts and commit signing do not work.

## TUI and ACP

* A TUI run in a VM holds at most 64 sessions. A further conversation started in it, such as with `/new`, is blocked with a message that says to start another run.
* In an ACP session, the MCP servers the editor provides are left out, with the warning `runtime_mcp_not_supported_in_vm`.
* A quest does not run members in a VM. A member whose backend is `vm` fails the quest before anything starts with `vm_quest_unsupported`. The fix is `pandra config set --agent AGENT backend host`.

## Errors

| Code | Fix |
|---|---|
| `backend_unsupported` | Run on the host backend. |
| `vm_entitlement_missing` | Install a release, or run `cargo xtask sign` in the checkout you built from. |
| `vm_workspace_too_broad` | Choose a narrower workspace with `--workspace DIR`. |
| `vm_asset_missing` | Run `pandra sync AGENT --backend vm` while online, or `pandra harness install NAME@VERSION --platform linux-arm64` under manual downloads. |
| `vm_image_unsupported` | Build the image `FROM` the base image, for `linux/arm64`. |
| `vm_disk_busy` | Wait for the named session's run to end, or stop it. |
| `vm_server_unsupported` | Run on the host backend, or replace the server. |
| `vm_login_expired` | Start the harness on your Mac once. |
| `vm_login_unsupported` | Use a target with an API key. |
| `vm_start_failed` | Check the image keeps the base image's OpenSSH server, socat, and `agent` account. With `--json`, `details.console` holds the VM console's last lines. |
| `vm_port_in_use` | Publish another host port, or free the port. |
| `vm_quest_unsupported` | `pandra config set --agent AGENT backend host`. |
| `not_available_in_vm` | Run the command on your Mac. |
| `harness_exited` | A VM that stops during a run, such as one out of memory, ends the run with this code. For memory, give the VM more with `--memory`. |
