# Run Hermes Agent tasks in clones

Hermes Agent's OSMates backend runs each task's tools in a new clone of a machine.

You need Hermes Agent 0.23.1 or later, the [command line](https://osmates.com/docs/install#add-the-command-line), and a copy of the OSMates repository.

## Install the plugin

1. In Terminal, open the folder of your copy of the OSMates repository.
2. Build the Python SDK and install the plugin with it:

```sh
python3 -m pip wheel --no-deps -w ~/.cache/osmates-wheels ./sdk/python
UV_FIND_LINKS=~/.cache/osmates-wheels hermes plugins install "file://$PWD#integrations/hermes" --enable --yes-deps
```

Keep the repository folder. Set `UV_FIND_LINKS` the same way for `hermes update` and `hermes plugins update`.

## Choose the machine each task clones

To use the backend and clone `dev` for each task:

```sh
hermes config set terminal.backend osmates
hermes config set terminal.container_persistent false
hermes config set plugins.entries.osmates.settings.machine dev
```

With `container_persistent` set to `true`, the backend refuses to run. Run `hermes doctor` to check the setup.

These settings are under `plugins.entries.osmates.settings`:

| Setting | What it does |
|---|---|
| `machine` | The machine or template each task clones. Empty clones the [template for agents](https://osmates.com/docs/templates#the-template-for-agents) |
| `snapshot` | A snapshot of that machine to clone instead |
| `user` | The guest account that runs commands. Empty runs them as root |
| `sandbox` | `true` makes each clone an [agent sandbox](https://osmates.com/docs/agent-sandbox), which requires OSMates Pro |

## Allow Hermes before an unattended run

The first task opens the question window for the Python that Hermes runs on. To allow it ahead, find its key with `osmates agents list`:

```sh
osmates agents list
osmates agents allow <key> --new-machines --scope lifecycle --for 24h
osmates agents allow <key> --vm dev --scope observe,lifecycle,exec_admin --for 24h
```

A clone gets the access Hermes has on its source.

## What each task gets

A task is one turn: one `hermes chat -q` run, one message in a chat, or one cron job run.

- The clone is deleted when the task ends, fails, or you stop it.
- The clone keeps its source's processor, memory, and network access. Hermes' `container_cpu`, `container_memory`, and `container_disk` don't apply.
- Hermes runs commands with bash, which Linux and macOS guests have.
- Hermes' credential files stay on your Mac. To give a clone a key, [grant it a credential](https://osmates.com/docs/credentials).
- Hermes asks before a dangerous command, as with its local backend. In `hermes chat -q`, its `approvals.single_query_mode` setting decides.

## If a clone stays

If OSMates can't delete a clone, Hermes' log names the clone and the command that deletes it. Run that command in Terminal.
