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

# Connect a Harness

> Send the OpenTelemetry data of Claude Code, Codex, omp, and GitHub Copilot to Cloud Uplink or a Self-Hosted Uplink instance.

An agent harness is the tool that runs a coding agent for a developer, such as Claude Code, Codex, omp, or GitHub Copilot. Point its OpenTelemetry export at an uplink instance with your publishing key, and Agent Golf records your sessions.

> [card] [Claude Code](https://docs.agent.golf/harnesses/claude-code.md)
>
> `settings.json` and the system keychain, or environment variables.

> [card] [Codex](https://docs.agent.golf/harnesses/codex.md)
>
> The `[otel]` table of `~/.codex/config.toml`.

> [card] [omp](https://docs.agent.golf/harnesses/omp.md)
>
> Standard OpenTelemetry environment variables.

> [card] [GitHub Copilot](https://docs.agent.golf/harnesses/copilot.md)
>
> `settings.json` and environment variables.

## Set up with the CLI

The `agentgolf` CLI creates a publishing key and writes the harness settings for you. [Install the CLI](https://docs.agent.golf/cli/install.md) first.

To set up each Claude Code, Codex, and GitHub Copilot harness on your machine with one command, run:

```bash theme={null}
agentgolf harness setup --all
```

The command signs you in, finds each harness on the machine, creates one personal publishing key for each harness, and writes its settings. It skips a harness whose settings file already has other values, and names the command that changes them. `--all` does not include omp. See [All harnesses on the machine](https://docs.agent.golf/cli/commands.md#all-harnesses-on-the-machine).

To set up one harness, give its name in place of `--all`. The **Harness Setup** card on **Settings > Uplink > Publishing Keys** shows the command for each harness. `agentgolf` 0.1.10 added `--all`. Run `agentgolf --version` to see your version.

For Cloud Uplink, run the command without `--endpoint`. Cloud Uplink must be on:

```bash theme={null}
agentgolf harness setup claude-code
```

For a Self-Hosted Uplink instance, give the base URL of its OTLP listener with `--endpoint`:

```bash theme={null}
agentgolf harness setup --all --endpoint 'http://127.0.0.1:4318'
```

The command writes the settings of each harness with every content setting on, and keeps the file's other settings. For Claude Code, it saves the publishing key in the system keychain. See [Claude Code](https://docs.agent.golf/harnesses/claude-code.md#publishing-key-in-the-system-keychain). For the files of each harness, `--replace`, and `--print`, see [`agentgolf harness setup`](https://docs.agent.golf/cli/commands#agentgolf-harness-setup).

* The command refuses an `http` endpoint whose host is not loopback, because the harness would send the key in plain text. Serve OTLP over TLS on the uplink instance with `OTLP_TLS_CERT_FILE` and `OTLP_TLS_KEY_FILE`, then use an `https` endpoint. See [Network](https://docs.agent.golf/uplink/network.md#secure-the-opentelemetry-listener). To send the key in plain text anyway, for example on a trusted private network, add `--allow-insecure-endpoint`.
* When the file already has other values for these settings, the command creates no key for that harness. Run it again for that harness with `--replace` to change them.
* For Claude Code, also set the content limit yourself. See [Content length](https://docs.agent.golf/harnesses/claude-code.md#content-length).

A harness reads its settings when it starts, so restart each running harness after the setup. A session that already started keeps its [contributor](https://docs.agent.golf/dashboard/sessions.md#contributor), so the key applies from the next session.

## Roll out to a team

An admin can roll out the shared harness settings to each developer, for example with MDM. Each developer then adds only their personal publishing key. `agentgolf` 0.1.10 added both commands.

1. For each harness, run `agentgolf harness managed-settings <harness>`, where `<harness>` is `claude-code`, `codex`, or `copilot`. The command prints the managed settings document of the harness. For a Self-Hosted Uplink instance, add `--endpoint <url>`. See [`agentgolf harness managed-settings`](https://docs.agent.golf/cli/commands#agentgolf-harness-managed-settings).
2. Push each document to the developer machines with MDM, or with the managed settings channel of the harness. Each harness page names the install places: [Claude Code](https://docs.agent.golf/harnesses/claude-code.md#team-rollout), [Codex](https://docs.agent.golf/harnesses/codex.md#team-rollout), and [GitHub Copilot](https://docs.agent.golf/harnesses/copilot.md#team-rollout).
3. Each developer runs `agentgolf harness setup --all` for Cloud Uplink. For a Self-Hosted Uplink instance, each developer runs `agentgolf harness setup --all --endpoint <url>` with the same URL that you gave in step 1. For Claude Code, the command saves the personal publishing key of the user in the system keychain. For Codex and GitHub Copilot, it adds the key to the harness file of the user.

The command signs in each developer with a code that they approve in a browser. An MDM script can run it only for a user who already ran `agentgolf login` on that device. Never run it with a shared `AGENTGOLF_ACCESS_TOKEN`: each key would belong to the owner of the token, not to the developer.

The managed documents hold no publishing key. Each key is personal, so it stays with each user: in the system keychain for Claude Code, and in the harness file for the other harnesses. Do not add a publishing key, or a header setting, to a managed document. A managed header replaces the key of each user. The Claude Code helper setting `otelHeadersHelper` holds no key, so an admin can add it to the managed settings. See [Claude Code](https://docs.agent.golf/harnesses/claude-code.md#team-rollout) for the order of that rollout.

## Manual setup requirements

Use these rules when you write the harness settings by hand or check them.

* **Endpoint.** For Cloud Uplink, its **OTLP Endpoint**, `https://uplink.agent.golf` in production. See [Cloud Uplink](https://docs.agent.golf/uplink/cloud.md#the-endpoint). For a Self-Hosted Uplink instance, its OTLP listener on port 4318. Use `https://` when Uplink serves TLS. For the addresses that each install listens on, see [Network](https://docs.agent.golf/uplink/network.md#listeners-and-default-binds).
* **Protocol.** OTLP over HTTP with Protobuf (`http/protobuf`), on `/v1/logs`, `/v1/metrics`, and `/v1/traces`. Uplink refuses OTLP JSON and compressed requests. The local agent of the GitHub Copilot extension in VS Code needs gRPC. See [VS Code local agent](https://docs.agent.golf/harnesses/copilot.md#vs-code-local-agent). For gRPC, see [Network](https://docs.agent.golf/uplink/network.md#listeners-and-default-binds) and [Cloud Uplink](https://docs.agent.golf/uplink/cloud.md#the-endpoint).
* **Publishing key.** Each harness sends its user's personal publishing key in the `x-agentgolf-publishing-key` header. See [Publishing keys](#publishing-keys).
* **Service name.** Keep the harness's default service name. Do not set `OTEL_SERVICE_NAME`. Claude Code and GitHub Copilot are the exceptions: set `OTEL_SERVICE_NAME=claude-code` for Claude Code and `OTEL_SERVICE_NAME=github-copilot` for GitHub Copilot, their defaults, so that a value that the shell inherits from another tool does not replace them. See [Claude Code](https://docs.agent.golf/harnesses/claude-code.md#settings) and [GitHub Copilot](https://docs.agent.golf/harnesses/copilot.md#3-the-environment-variables).
* **Private CA.** If the Uplink certificate comes from a private CA, give the harness the CA bundle. Each harness page shows how.

## Publishing keys

A publishing key is a personal key (`agk_...`). Your harness sends it with its telemetry, and Agent Golf links your sessions to you as their [contributor](https://docs.agent.golf/dashboard/sessions.md#contributor). One key works with Cloud Uplink and with a Self-Hosted Uplink instance. You need the **Connect Your Harness** permission. See [Default roles](https://docs.agent.golf/account/users.md#default-roles).

To create a key and copy the harness settings in the dashboard:

1. Open **Settings > Uplink > Publishing Keys**. The page does not need Cloud Uplink to be on.
2. In the **Your Publishing Keys** card, enter a **Key Name**, for example the name of your machine, and select **Create Publishing Key**.
3. Copy the secret. Agent Golf keeps only a digest of the secret and cannot show it again.
4. In the **Harness Setup** card, select the uplink instance. When Cloud Uplink is on, choose **Cloud Uplink** or **Self-Hosted**. When it is off, the card shows only the settings for a Self-Hosted Uplink instance.
5. For a Self-Hosted Uplink instance, enter the address of its listener in **OTLP Endpoint of Your Uplink Instance**. The default is `http://127.0.0.1:4318`. The card shows a warning when the address sends the key in plain text to a host that is not loopback.
6. In **Harness**, select **Claude Code**, **Codex**, **omp**, or **GitHub Copilot**, and copy the settings. While the secret shows, the settings include it. After you select **Hide Secret**, they show `<publishing-key>` in its place. Under **Or run:**, the card shows the CLI command that writes the same settings.

Each secret is a credential: anyone who has it can send telemetry to your workspace. Keep it in your harness settings or a secret store, never in a repository. Use one key for each machine, so that you can revoke one key and keep the others. To revoke a key, select **Revoke** in its row.

**Last Used** shows the last time that an uplink instance published telemetry with the key. Agent Golf records it at most once an hour. For a Self-Hosted Uplink instance, Agent Golf records the use when it links a session to the key owner.

How each uplink instance treats a key:

* **Cloud Uplink** accepts a key only while one of the owner's roles includes **Connect Your Harness**. When an admin changes the owner's role to Viewer, Cloud Uplink refuses the key with `401`. When the owner gets the permission back, the same key works again. Each change takes effect within one minute.
* **A Self-Hosted Uplink instance** refuses an export without a well-formed key. It also refuses a revoked key with `401`, within one minute after the revocation. It does not check the owner's role: Agent Golf links its sessions to the key owner while the owner is a user of the workspace, even after the owner loses **Connect Your Harness**. See [Require a publishing key](https://docs.agent.golf/uplink/install.md#require-a-publishing-key).
* When a user leaves the workspace, Agent Golf revokes their keys.

## A collector between the harness and Uplink

An OpenTelemetry Collector or Grafana Alloy between the harnesses and Uplink drops the request headers by default. To keep the link to each key owner, configure the collector to forward each export's `x-agentgolf-publishing-key` header. The same settings work for Cloud Uplink and for a Self-Hosted Uplink instance. Only the exporter endpoint changes.

1. Connect each harness to the collector with its user's personal publishing key. `agentgolf harness setup <harness> --endpoint <collector-url>` sets up the harness to send the key in the header.
2. In the OTLP receiver, set `include_metadata` to keep the request headers.
3. In the batch processor, when the pipeline has one, name the header in `metadata_keys`, so that each batch holds the exports of one key.
4. On the Uplink exporter, set the header `from_context` with a header setter. When an export has no key, the setter sends an empty header, and Uplink treats it as absent.
5. Turn off compression on the Uplink exporter. Uplink refuses compressed requests, and the `otlphttp` exporter and the Alloy client compress with gzip by default.

> [!WARNING]
>
> Give the header setter only to the Uplink exporter. Do not copy the key into a resource attribute or another
> attribute, because every exporter sends the attributes to its backend.

Replace `<uplink-endpoint>` with `https://uplink.agent.golf` for Cloud Uplink, or with the listener of your Self-Hosted Uplink instance, for example `https://uplink.example.internal:4318`. For Cloud Uplink, the **Collector Setup** card on **Settings > Uplink > Cloud** shows the same configuration with your endpoint.

> [tab] OpenTelemetry Collector
>
> Use the [`headers_setter` extension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/headerssetterextension/README.md) of the contrib distribution:
>
> ```yaml theme={null}
> receivers:
>   otlp:
>     protocols:
>       http:
>         include_metadata: true
>
> processors:
>   batch:
>     metadata_keys: [x-agentgolf-publishing-key]
>
> extensions:
>   headers_setter/agentgolf:
>     headers:
>       - key: x-agentgolf-publishing-key
>         from_context: x-agentgolf-publishing-key
>
> exporters:
>   otlphttp/agentgolf:
>     endpoint: <uplink-endpoint>
>     encoding: proto
>     compression: none
>     auth:
>       authenticator: headers_setter/agentgolf
>
> service:
>   extensions: [headers_setter/agentgolf]
>   pipelines:
>     traces:
>       receivers: [otlp]
>       processors: [batch]
>       exporters: [otlphttp/agentgolf]
>     metrics:
>       receivers: [otlp]
>       processors: [batch]
>       exporters: [otlphttp/agentgolf]
>     logs:
>       receivers: [otlp]
>       processors: [batch]
>       exporters: [otlphttp/agentgolf]
> ```

> [tab] Grafana Alloy
>
> Use [`otelcol.auth.headers`](https://grafana.com/docs/alloy/latest/reference/components/otelcol/otelcol.auth.headers/):
>
> ```alloy theme={null}
> otelcol.receiver.otlp "default" {
>   http {
>     include_metadata = true
>   }
>
>   output {
>     logs    = [otelcol.processor.batch.default.input]
>     metrics = [otelcol.processor.batch.default.input]
>     traces  = [otelcol.processor.batch.default.input]
>   }
> }
>
> otelcol.processor.batch "default" {
>   metadata_keys = ["x-agentgolf-publishing-key"]
>
>   output {
>     logs    = [otelcol.exporter.otlphttp.uplink.input]
>     metrics = [otelcol.exporter.otlphttp.uplink.input]
>     traces  = [otelcol.exporter.otlphttp.uplink.input]
>   }
> }
>
> otelcol.auth.headers "agentgolf" {
>   header {
>     key          = "x-agentgolf-publishing-key"
>     from_context = "x-agentgolf-publishing-key"
>   }
> }
>
> otelcol.exporter.otlphttp "uplink" {
>   client {
>     endpoint    = "<uplink-endpoint>"
>     compression = "none"
>     auth        = otelcol.auth.headers.agentgolf.handler
>   }
> }
> ```

An export without a key gets `401`, so make sure that each harness sends its key.

## Session content

By default, Claude Code, omp, and the GitHub Copilot CLI send only the shape of their activity: lengths, tool names, and token counts. Codex also sends tool arguments and tool output by default. The GitHub Copilot extension for VS Code sends prompts and tool content with every setting. Each harness has settings that add more content, such as prompt text. The CLI and the **Harness Setup** card turn on every content setting. Remove the settings that your policy does not allow before you use the harness. Each harness page lists its content settings.

The harness sends this content only to the uplink instance. A Self-Hosted Uplink instance keeps it on your infrastructure, and Agent Golf receives only opaque references to it. Cloud Uplink keeps it on Agent Golf infrastructure. See [What Leaves Your Network](https://docs.agent.golf/getting-started/data-boundary.md).

With less content, the dashboard has less to show, and Agent Golf links fewer sessions to pull requests automatically.

## Link a session to a pull request

When automatic attribution finds no pull request for your session, you can link it by hand. See [Link a session by hand](https://docs.agent.golf/dashboard/attribution.md#link-a-session-by-hand).

## Verify the setup

1. Start a session in the harness and send a prompt.
2. Open **Sessions** in the dashboard. The session shows in **Recent Sessions**. To find it, set the **Harness** filter to your harness.

If no session shows, check the harness endpoint, publishing key, and protocol (`http/protobuf`). For Cloud Uplink, see [Verify the setup](https://docs.agent.golf/uplink/cloud.md#verify-the-setup). For a Self-Hosted Uplink instance, see [Troubleshoot Uplink](https://docs.agent.golf/uplink/troubleshooting.md).


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