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

# Run two agents

> A second agent on another machine keeps the dataset online when the first one stops.

One agent is one machine. When it stops, the dataset stops answering. Run a second agent on another machine, and Concatflow sends each request to whichever agent is connected.

Every agent of a dataset gets the requests of that dataset. Concatflow hands each request to a single agent. When one agent disconnects, the next requests go to the other one, with nothing to configure.

**1. Generate a token for the second agent**

Each agent needs its own token. Open the dataset, go to its settings, and select **Add an agent**. Then **Generate a token**.

**2. Start the agent on another machine**

Use the same command as the first agent, with the new token and a different `--hostname`:

```bash theme={"system"}
docker run -d --name cubit-agent --restart unless-stopped \
  --hostname db-agent-2 \
  -e CUBIT_ENROLL_TOKEN=<new-token> \
  -e CUBIT_API_URL=https://api.concatflow.com \
  -e DATABASE_URL="postgresql://concatflow_reader:<password>@<host>:5432/app" \
  -v cubit-agent:/data \
  ghcr.io/usecubit/source-client:0.1.0
```

**3. Check both are online**

The dataset settings list both agents, each marked **Online**.

Both agents can use the same database account. They do not need to know about each other.

When no agent is connected, requests to the dataset fail with `no agent is connected for this dataset`.

> [!TIP]
>
> Agents on two machines protect you from a machine going down. They do not protect you from the database going down.


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