> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boxd.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Argon

> Run agent-written code on an isolated boxd machine against an Argon MongoDB sandbox, then review the diff before anything reaches your data.

![The Argon logo mark and wordmark inside the boxd card.](https://mintcdn.com/azin/YgZNOc02fe3RwN8T/images/boxd-x-argon.png?fit=max\&auto=format\&n=YgZNOc02fe3RwN8T\&q=85\&s=2cbc4fb556c17be019a536c536c28b89)

[Argon](https://github.com/argon-lab/argon) gives every agent run its own real MongoDB database, forked from your data. What the agent writes becomes a diff: you review it, merge what you want and discard the rest.

Argon's repository has an example that pairs it with boxd ([pull request](https://github.com/argon-lab/argon/pull/101)). The agent's code runs on an isolated boxd machine and writes to an Argon sandbox. You get two sandboxes: boxd for the code, Argon for the data.

> [card] [The example's README](https://github.com/argon-lab/argon/tree/master/examples/boxd-sandbox#readme)
>
> The full guide: setup, credentials, the port check and clean up. Start there.

## How it works

```text theme={"theme":"github-dark"}
data machine                                 agent machine (isolated)
  MongoDB, Argon console, host.py  ───▶      agent.py
  1. Argon sandbox + restricted user         2. writes through PyMongo
  3. diff, then discard (or --apply)  ◀───   network: argon-example only
```

* **Two machines.** MongoDB, the Argon console and `host.py` run on a data machine. The agent's code runs on a second machine that `host.py` creates for each run with `isolated` and the `argon-example` [network](https://docs.boxd.sh/guides/vm-to-vm.md#networks). It reaches the data machine at `<data-machine>.boxd:27017` and no other machine you own.
* **No internet for the agent's code.** The agent machine installs PyMongo first. Then `host.py` sets its [egress allowlist](https://docs.boxd.sh/guides/egress-allowlist.md) to `none`, so the code can reach MongoDB and nothing else. SSH is off.
* **A database user per run.** The agent never gets Argon's connection string. `host.py` creates a MongoDB user with `readWrite` on the sandbox's database only, passes it on the command's stdin, and drops it when the run ends.
* **Review first.** A default run prints the diff and discards the sandbox, so your main branch stays as it was. `--apply` merges the diff of its own run.

## Run it

**1. Create the data machine and an API key**

```bash theme={"theme":"github-dark"}
boxd machine new argon-data --networks=argon-example --region nyc
boxd auth keys create argon-example
boxd connect argon-data
```

On the data machine, start MongoDB as a one-node replica set with authentication, install Argon (2.3.1 or newer, `npm install -g argonctl`) and start `argon console`. The README has the exact commands.

**2. Check port 27017**

The README's check pings MongoDB from an isolated machine on `argon-example` and from one outside it. Only the first may answer:

```text theme={"theme":"github-dark"}
ping27017 argon-check argon-data.boxd              # prints 1
ping27017 argon-outside argon-data.boxd            # prints not reachable
ping27017 argon-outside argon-data.nyc.boxd.sh     # prints not reachable
```

**3. Run the example**

On the data machine:

```bash theme={"theme":"github-dark"}
git clone https://github.com/argon-lab/argon.git && cd argon
python3 -m venv ~/argon-example && ~/argon-example/bin/pip install 'boxd>=0.3.2' pymongo
read -rs BOXD_API_KEY && export BOXD_API_KEY
~/argon-example/bin/python examples/boxd-sandbox/host.py --network argon-example --region nyc
```

```text theme={"theme":"github-dark"}
boxd machine argon-agent-<run-id> (<machine-id>)
agent: {"database": "argon_br_<id>", "closed": 1, "escalated": 1}
change: {"collection": "tickets", "document_id": "T-1", ... "status": "closed"}, ... "before": {... "status": "open"}}
change: {"collection": "tickets", "document_id": "T-2", ... "status": "escalated"}, ... "before": {... "status": "open"}}
change: {"collection": "triage_notes", "document_id": "triage-1", "document": {"_id": "triage-1", "closed": 1, "escalated": 1}, ...}
discarded the sandbox; run again with --apply to merge
```

The run took about 17 seconds, the agent machine included. `host.py` deletes the agent machine at the end.

**4. Merge after review**

```bash theme={"theme":"github-dark"}
~/argon-example/bin/python examples/boxd-sandbox/host.py --network argon-example --region nyc --apply
```

```text theme={"theme":"github-dark"}
applying merge plan <plan-id>
```

Each run starts a new project, agent machine and sandbox, so `--apply` merges the diff of its own run.

`agent.py` stands in for code an agent would write, so no LLM account is needed. Replace it with your agent's code and keep the rest.

## Clean up

The data machine and the API key stay until you remove them:

```bash theme={"theme":"github-dark"}
boxd machine remove argon-data -y
boxd auth keys remove argon-example
```

## Read more

* [The example's README](https://github.com/argon-lab/argon/tree/master/examples/boxd-sandbox#readme): every command, credentials and options like `--keep-machine`
* [Argon on GitHub](https://github.com/argon-lab/argon)
* [Networks](https://docs.boxd.sh/guides/vm-to-vm.md#networks) and [egress allowlists](https://docs.boxd.sh/guides/egress-allowlist.md) on boxd
* [Sandboxes on boxd](https://docs.boxd.sh/use-cases/sandboxes.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.