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

# Connect an OpenClaw Agent

> Install the BenchGen plugin in your OpenClaw gateway to get traces, benchmarks, datasets and chat for the agent. One setup, nothing inbound to your gateway.

[OpenClaw](https://github.com/openclaw/openclaw) runs your agent inside a gateway; BenchGen connects to it through the plugin package `@benchgen/benchgen-openclaw`.

You need a gateway `2026.7.2` or newer and plugin `0.3.0` or newer (older combinations only trace: `2026.7.1` lacks the chat bridge hook, plugin `0.2.x` cannot chat), and an agent record in BenchGen: if you have none yet, create one under **My Agents** → **Create New Agent**. Everything you will paste, the key pair, the endpoint and the chat relay URL, is on that agent's **Observability** card on its **Overview** tab.

## Ways to connect

Three ways to put the configuration in place; pick by what kind of access you have to the gateway.

### A. Command line

**1. Install the plugin**

```bash theme={null}
openclaw plugins install @benchgen/benchgen-openclaw
```

If the gateway is already running, restart it after the install.

**2. Configure the plugin**

```bash theme={null}
openclaw benchgen configure
```

The wizard prompts for the public key, secret key and endpoint, verifies that the keys reach BenchGen, asks whether BenchGen may chat with the agent (default **yes**) and for the chat relay URL (paste `BENCHGEN_CHAT_URL` from the card; Enter keeps the built-in default, which is the production relay), enables the plugin and writes plugin-scoped config to `plugins.entries.benchgen`.

**3. Restart the gateway and check status**

How you restart depends on the hosting: `docker restart <container>` for a Docker gateway, or the restart control in your hosting panel. Then:

```bash theme={null}
openclaw benchgen status
openclaw plugins info benchgen
```

`Enabled: yes` and `Status: loaded` mean the plugin is running. Now [verify](#verify).

### B. Setup prompt

![The Observability card with the agent's key pair, trace status and the Copy setup prompt button](https://mintcdn.com/benchgen-8fc81371/oXzVpf1EVd5pntSt/images/agentspace/openclaw/02a-setup-prompt.png?fit=max\&auto=format\&n=oXzVpf1EVd5pntSt\&q=85\&s=13b4bd22d0a4dcb171c7c4bd6ceb1b35)

The Observability card: the agent's key pair, its trace status, and under Sending traces from OpenClaw the Copy setup prompt button

On the **Observability** card, open the **Ask your agent** tab, click **Copy setup prompt**, and paste it into a session with the agent that runs your gateway. The prompt already contains your public key, endpoint and chat relay URL; it tells the agent to install the plugin, write the config, and restart the gateway, so the agent's tool profile has to allow shell execution.

> [!WARNING]
>
> **The secret key is not in the prompt, deliberately.** A prompt goes into chat history and usually into a model provider's logs. The agent will ask for it separately.

Then check the result yourself at [Verify](#verify). An agent reporting success is not the same as a trace arriving.

> [accordion] What the prompt says
>
> Your copy carries your agent's real public key in place of the placeholder; the URLs below are the production values, and your copy has the ones for your BenchGen environment.
>
> ```
> Set up BenchGen tracing in this OpenClaw gateway.
>
> Follow these steps exactly. Do not invent configuration keys: every name below
> is read verbatim by the plugin.
>
> ## 1. Install the plugin
>
>     openclaw plugins install @benchgen/benchgen-openclaw
>
> ## 2. Get the secret key from me
>
> Four values are needed. Three are here; the fourth is a secret and is NOT in this
> prompt:
>
>   publicKey: pk-lf-YOUR-PUBLIC-KEY
>   baseUrl:   https://traces.benchgen.com
>   chatUrl:   wss://benchgen.com/api/public/openclaw/chat
>   secretKey: ASK ME FOR IT. It is on the BenchGen agent page I copied this from,
>              in the Observability card. Do not guess it, do not invent a
>              placeholder, and do not continue without it.
>
> ## 3. Write the configuration
>
> Merge this into the gateway's `openclaw.json`, keeping any other entries that
> are already under `plugins.entries`:
>
>     {
>       "plugins": {
>         "entries": {
>           "benchgen": {
>             "enabled": true,
>             "config": {
>               "enabled": true,
>               "publicKey": "pk-lf-YOUR-PUBLIC-KEY",
>               "secretKey": "<the key I give you>",
>               "baseUrl": "https://traces.benchgen.com",
>               "chat": { "url": "wss://benchgen.com/api/public/openclaw/chat" }
>             }
>           }
>         }
>       }
>     }
>
> Both `enabled` flags have to be true: the outer one turns the plugin entry on,
> the inner one turns tracing on, and the plugin checks both.
>
> The `chat.url` is where the plugin dials in so BenchGen can chat with the agent
> (the Runtime card connects itself once the gateway is up). It is on by default;
> set `"chat": { "enabled": false }` to opt out.
>
> `benchgen` is the plugin's manifest id, which is not its npm package name. An
> unknown id under `plugins.entries` is a configuration error the gateway refuses
> to start on, so do not change that string.
>
> Instead of putting the keys in the file, you may set `BENCHGEN_PUBLIC_KEY`,
> `BENCHGEN_SECRET_KEY`, `BENCHGEN_BASE_URL` and `BENCHGEN_CHAT_URL` in the gateway's environment; the
> plugin falls back to those when the config omits them.
>
> ## 4. Restart the gateway
>
> The configuration is only read at startup, so nothing happens until you restart
> the gateway. This is the most common reason setup appears to fail.
>
> ## 5. Verify
>
> On every start the plugin sends a trace named `benchgen.plugin.connected`,
> tagged `benchgen-setup`. Tell me to look for it on the Traces tab. That trace
> is the gateway confirming it reached BenchGen, and it is the only real proof
> this worked.
>
> If nothing arrives, check the credentials themselves:
>
>     curl -s -o /dev/null -w '%{http_code}\n' \
>       -u 'pk-lf-YOUR-PUBLIC-KEY:<the key I give you>' \
>       'https://traces.benchgen.com/api/public/health'
>
> 200 means the keys are good and the problem is the config or the restart. 401
> means the keys are wrong.
>
> ## Do not
>
> - Do not run `openclaw benchgen configure`. It prompts interactively and cannot be
>   driven from this conversation; the JSON in step 3 is its exact equivalent.
> - Do not print the secret key back to me, and do not write it anywhere except
>   the gateway configuration or its environment.
> ```

### C. Manual JSON

Use this when you need explicit checked-in or templated plugin configuration, or when your only access is the Control UI's raw config editor (**Settings** → **Advanced** → **Settings** → **Raw**).

Add this to your OpenClaw config, at the root level. The URLs are the production values; on another BenchGen environment use the `BENCHGEN_BASE_URL` and `BENCHGEN_CHAT_URL` from the Observability card. The key pair is your agent's own, also on the card:

```json theme={null}
{
  "plugins": {
    "entries": {
      "benchgen": {
        "enabled": true,
        "config": {
          "enabled": true,
          "publicKey": "pk-...",
          "secretKey": "sk-...",
          "baseUrl": "https://traces.benchgen.com",
          "chat": {
            "url": "wss://benchgen.com/api/public/openclaw/chat"
          }
        }
      }
    }
  }
}
```

Both `enabled` flags have to be true: the outer one loads the plugin, the inner one turns on streaming. `benchgen` is the plugin's manifest id, not its npm package name. `chat.url` is the card's `BENCHGEN_CHAT_URL`; leave it out only if the card's value equals the plugin's built-in default (the production relay).

The environment fallbacks `BENCHGEN_PUBLIC_KEY`, `BENCHGEN_SECRET_KEY`, `BENCHGEN_BASE_URL` and `BENCHGEN_CHAT_URL` are read when the matching config key is absent, and `BENCHGEN_CHAT_ENABLED=false` switches chat off the same way. Setting all four on the container skips the wizard entirely. Restart the gateway after editing.

> [!WARNING]
>
> Back up `openclaw.json` first. OpenClaw refuses to start on an invalid config: an unknown plugin id or a wrong type stops the gateway, and the Control UI goes down with it.

## Verify

Every time the plugin starts with valid configuration it sends one trace of its own:

```
benchgen: sent startup trace "benchgen.plugin.connected" to https://...
```

Look for it in the **Logs** tab of the Control UI, and on your agent's **Traces** tab as `benchgen.plugin.connected`, tagged `benchgen-setup`. The **Observability** card flips from *Waiting for first trace* to *Traces arriving* when it lands, with no page reload.

With chat enabled the gateway log also shows the relay coming up (`relay connected`), and within a few seconds the agent's **Settings** → **Runtime** card reads *connected through the BenchGen OpenClaw plugin* with an **Open chat** button.

![The Runtime card showing the endpoint, protocol via BenchGen relay, gateway online and the Open chat button](https://mintcdn.com/benchgen-8fc81371/oXzVpf1EVd5pntSt/images/agentspace/openclaw/03-runtime-relay-connected.png?fit=max\&auto=format\&n=oXzVpf1EVd5pntSt\&q=85\&s=731feedfa1dc1d645fc6466464cbc206)

The Runtime card once the plugin has dialled in: endpoint, protocol via BenchGen relay, gateway online, Open chat

That card polls on its own; if it still shows *OpenClaw plugin connected, Connecting it for chat…* after a minute, see [Troubleshooting](#troubleshooting).

Wrong credentials fail loudly rather than silently:

```
benchgen: startup trace failed, streaming is still active: Unauthorized
```

Streaming stays subscribed either way; a rejected handshake never stops the plugin. The relay, on the other hand, refuses unknown keys (the gateway log shows the socket closing with `4401`) and retries with backoff until the keys are right.

> [!TIP]
>
> On OpenClaw 2026.7.2 a config edit hot-reloads: the logs show `config change detected` followed by a fresh handshake, no restart. Only new plugin **code** needs a restart.

These handshake traces accumulate, since a config edit counts as a start. Filter the Traces tab by tag `benchgen-setup` to isolate them, or to scan past them.

Then send your agent a few ordinary messages. Those produce the real traces.

## First traces

The **Traces** tab is the agent's own trace store, read with the keys on the Observability card. One project per agent, so nothing from other agents is mixed in.

One trace per message the agent handles. After the handshake, send the agent a few ordinary messages and they appear here within seconds; that is what a freshly connected agent should look like:

![The Traces tab with chat turns, gateway handshakes and heartbeats](https://mintcdn.com/benchgen-8fc81371/oXzVpf1EVd5pntSt/images/agentspace/openclaw/05-traces-tab.png?fit=max\&auto=format\&n=oXzVpf1EVd5pntSt\&q=85\&s=f6cd67e36bc2d97ab74c5647c3204bb5)

The Traces tab right after connecting: chat turns, gateway handshakes and heartbeats, with filters and a time range

What you will see named there: OpenClaw's own periodic turns arrive as `heartbeat` (input `[OpenClaw heartbeat poll]`), turns that came from BenchGen (chat and benchmarks) as `benchgen`, and every trace carries an `agent:<id>` tag for the gateway agent that ran it (`agent:main` on a default gateway). Handshakes are tagged `benchgen-setup`; filter by that tag to isolate them, or to scan past them.

Keys can be rotated from the Observability card (**Rotate keys**). Update the gateway's config afterwards; the old pair stops working.

A connected agent is registered as a model, so benchmarks run against it like against any other model: running one, watching its live log and reading the run's traces task by task is on [Benchmark an OpenClaw Agent](https://benchgen.com/docs/agentspace/benchmark-openclaw-agent.md); turning traces into datasets is on [Datasets from an OpenClaw Agent](https://benchgen.com/docs/agentspace/datasets-openclaw-agent.md).

## Chat

Chat needs nothing beyond the plugin. On its first `hello` over the relay, BenchGen connects the agent for chat: the agent becomes available in BenchGen's chat and gets registered for benchmarks. Until then the **Runtime** card reads *Waiting for the gateway*; from then on it shows **Open chat**.

![BenchGen chat with a connected OpenClaw agent answering a question](https://mintcdn.com/benchgen-8fc81371/oXzVpf1EVd5pntSt/images/agentspace/openclaw/07-chat-conversation.png?fit=max\&auto=format\&n=oXzVpf1EVd5pntSt\&q=85\&s=50b941baa7940b1247fadf80fed21cc8)

A conversation with a connected OpenClaw agent, opened straight from the Runtime card

> [card] [Chat with an OpenClaw Agent](https://benchgen.com/docs/agentspace/chat-openclaw-agent.md)
>
> Sessions, streaming, switching chat off, and reconnecting.

> [card] [Benchmark an OpenClaw Agent](https://benchgen.com/docs/agentspace/benchmark-openclaw-agent.md)
>
> Run it against an environment and read the trace.

## What the install gives you

Everything above came from the one plugin install, and all of it is **outbound from the gateway**: traces go to the BenchGen endpoint, chat rides on a WebSocket the plugin keeps open, so the gateway can sit behind NAT, Docker, or a firewall. This is where each piece lives from now on:

| You get | How | Where you see it |
| - | - | - |
| **Traces** | The plugin streams every turn the agent handles, with model calls and tool executions nested under it. | The agent's **Traces** tab |
| **Benchmarks** | A connected agent is registered as a model, so benchmarks run against it like against any other model. | A benchmark's **Evaluate** tab, under **Platform Models**; results on the agent's **Evaluations** tab |
| **Datasets** | Traces you pick become dataset items: for training, annotation, or as benchmark material. | **Traces** → **Add to dataset**; then **Datasets** and **Train** |
| **Chat** | The gateway dials out to BenchGen's chat relay; BenchGen connects the agent for chat on its own the moment the gateway comes up. | **Settings** → **Runtime**, then **Open chat** |

Continue with [Benchmark an OpenClaw Agent](https://benchgen.com/docs/agentspace/benchmark-openclaw-agent.md), [Datasets from an OpenClaw Agent](https://benchgen.com/docs/agentspace/datasets-openclaw-agent.md) and [Chat with an OpenClaw Agent](https://benchgen.com/docs/agentspace/chat-openclaw-agent.md).

## Troubleshooting

Three symptoms cover almost everything.

**No handshake trace after restarting.** Read the gateway log and match the line:

| Log line | Fix |
| - | - |
| `missing publicKey/secretKey` | Credentials never reached the plugin. Check `openclaw benchgen status`. |
| `disabled via config (enabled === false)` | Both `enabled` flags (outer entry, inner config) need to be `true`. |
| `startup trace failed: Unauthorized` | Wrong keys. Copy the pair again from the **Observability** card. |
| `Plugin not found: <id>` | Use the manifest id `benchgen`, not the npm package name. |
| No `benchgen` lines at all | The plugin didn't load. Check `openclaw plugins info benchgen` for `Status: loaded`. |

> [accordion] Less common log lines
>
> | Log line | Cause |
> | - | - |
> | `diagnostics are disabled (config.diagnostics.enabled === false)` | The plugin has nothing to listen to. Set `diagnostics.enabled` to `true`. |
> | `plugin requires plugin API >=X, but this host is Y; skipping discovery` | The OpenClaw build is too old. Upgrade the image through your hosting panel. |
> | `EPERM: operation not permitted, chmod '/home/node/.openclaw'` | The config directory isn't writable by the gateway's user (`node`, uid 1000). Fix on the hosting side. |

**Chat does not come up.** The gateway log shows the relay's close code:

| Code | Fix |
| - | - |
| `4401` | Unknown keys. Copy both again from the card. |
| `4403` | Keys were rotated. Update the gateway. |
| `4408` | A proxy is breaking the WebSocket connection. |
| `4409` | Two gateways share one agent's keys. Give each gateway its own agent. |

> [accordion] Other chat symptoms
>
> | Symptom | Cause |
> | - | - |
> | `chat bridge not started` in the log | The gateway is older than `2026.7.2`. Traces still flow; upgrade the image to get chat. |
> | Runtime card stuck on *Connecting it for chat…* | BenchGen couldn't register the agent for chat yet. Click **Connect now** to retry. |
> | Runtime card says *switched off* | Someone clicked **Disconnect**. Click **Connect** to bring it back. |
> | *Agent gateway did not pick up the message* in chat | The gateway dropped off the relay mid-turn, or `chat.enabled` is `false`. |
> | Wrong `chat.url` | The plugin dials the production relay by default. On another BenchGen environment, set it to the card's `BENCHGEN_CHAT_URL`. |

**Gateway won't start after a config edit.** Restore `openclaw.json.bak` through your hosting panel — an unknown key or wrong type blocks startup.

> [!TIP]
>
> An agent saying setup worked isn't proof. The handshake trace (`benchgen.plugin.connected` on the **Traces** tab) is the only confirmation that doesn't depend on the agent's word.

## Upgrade the plugin

```bash theme={null}
openclaw plugins update benchgen
```

From the Control UI, send it as `Run: openclaw plugins update benchgen`. Restart the gateway afterwards to load the new code.

`plugins install` refuses to overwrite a plugin that is already present; use `update`, or `--force`.

Upgrading from `0.2.x`: chat is on by default in `0.3.0`. Run `openclaw benchgen configure` once to set the chat relay URL (or add `chat.url`), or set `"chat": { "enabled": false }` if you only want traces.


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