# convoy stop

> Stop a whole swarm run or a single agent. Stopping a swarm ends its run as Stopped, after which convoy run can start a new one.

```text
convoy stop <swarm> [<agent>]
```

## What it does

Sends `{"reason": "stopped from the CLI"}` to the server and prints the resulting status. It acts on the latest run.

- `convoy stop <swarm>` calls `POST /v1/swarms/{name}:stop`. Every non-terminal agent is stopped: processes are killed and tokens revoked. The run ends as Stopped with reason `stopped`, and `convoy run` may then start a new run of that name.
- `convoy stop <swarm> <agent>` calls `POST /v1/swarms/{name}/agents/{agent}:stop`. The agent's children are stopped first, depth first, then the agent. The rest of the swarm keeps running.

Both are idempotent: stopping something already in a terminal state succeeds and changes nothing.

## Examples

```console
$ convoy stop edge_chips
swarm "edge_chips" run 3 STOPPED (stopped), spend $4.87
```

```console
$ convoy stop edge_chips researcher[tenstorrent]
agent "researcher[tenstorrent]" stopped
```

Free the name, then start over:

```console
$ convoy stop edge_chips && convoy run
```

## Notes

Stopping the whole swarm is the only way to replace a running one, because [`convoy run`](/docs/cli/run/) refuses with `swarm_active`. A run stopped by a human has end reason `stopped`. Runs stopped by the server itself end with `budget` or `max_runtime`. Outputs already produced are kept and readable with `convoy status --run N`.

The agent form needs the caller to be the CLI, the overseer, or the agent's parent. The CLI always qualifies.

## Exit codes

| Code | Cause |
| --- | --- |
| `0` | Stopped, or already in a terminal state |
| `1` | Unknown swarm or agent (404), or server unreachable |
| `2` | Missing argument |

## API endpoints

- `POST /v1/swarms/{name}:stop`
- `POST /v1/swarms/{name}/agents/{agent}:stop`

## Related

- [convoy status](/docs/cli/status/)
- [Swarms and runs](/docs/concepts/swarms/)
- [Controller](/docs/runtime/controller/)
