> ## 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.

# Codex

> Send the OpenTelemetry data of Codex to Cloud Uplink or a Self-Hosted Uplink instance.

Codex exports OpenTelemetry logs, traces, and metrics. It reads its export settings from the `[otel]` table of the user-level `~/.codex/config.toml`, and from the managed and system configuration that your administrators deploy. A project-level `.codex/config.toml` cannot set them.

## Settings

The **Harness Setup** card on **Settings > Uplink > Publishing Keys** shows these settings, and `agentgolf harness setup codex` writes them to `~/.codex/config.toml`, or to `$CODEX_HOME/config.toml`. See [Set up with the CLI](https://docs.agent.golf/harnesses/overview.md#set-up-with-the-cli). To copy them by hand, replace:

* `<endpoint>` with `https://uplink.agent.golf` for Cloud Uplink, or with the listener of your Self-Hosted Uplink instance, for example `http://127.0.0.1:4318`.
* `<publishing-key>` with your personal publishing key. See [Publishing keys](https://docs.agent.golf/harnesses/overview.md#publishing-keys).

```toml theme={null}
# ~/.codex/config.toml
[otel]
log_user_prompt = true
metrics_exporter = "none"

[otel.exporter.otlp-http]
endpoint = "<endpoint>/v1/logs"
protocol = "binary"
headers = { x-agentgolf-publishing-key = "<publishing-key>" }

[otel.trace_exporter.otlp-http]
endpoint = "<endpoint>/v1/traces"
protocol = "binary"
headers = { x-agentgolf-publishing-key = "<publishing-key>" }
```

* Each endpoint includes the full signal path: `/v1/logs` or `/v1/traces`.
* Use `otlp-http` with `protocol = "binary"`. A Self-Hosted Uplink instance with its gRPC listener on also accepts `otlp-grpc` on port 4317, without the signal path. Cloud Uplink also accepts `otlp-grpc` at `https://uplink.agent.golf`. See [Protocol](https://docs.agent.golf/harnesses/overview.md#manual-setup-requirements).
* Keep both the log exporter and the trace exporter. Uplink needs both signals.
* Set `metrics_exporter = "none"`. Uplink does not use Codex metrics.
* Codex does not replace environment variables in `headers`. Put the secret itself in the file, and let only your user read the file.

Keep the default Codex service name and settings.

## Team rollout

Codex merges its configuration layers table by table, key by key. A key in a layer replaces the same key in all layers below it. A table that a layer does not set, or a key that a table does not hold, keeps its value from the lower layers. From the lowest to the highest precedence, the layers that can set `[otel]` are:

1. The system file: `/etc/codex/config.toml`, or `%ProgramData%\OpenAI\Codex\config.toml` on Windows.
2. The cloud configuration of a ChatGPT Business or Enterprise workspace.
3. The user file: `~/.codex/config.toml`, or `$CODEX_HOME/config.toml`.
4. The legacy `managed_config.toml` file.
5. The macOS managed preferences of domain `com.openai.codex`, key `config_toml_base64`. Deploy them with an MDM profile.

So your administrators can set the shared settings for each developer, and each developer adds only their personal publishing key. See [Roll out to a team](https://docs.agent.golf/harnesses/overview.md#roll-out-to-a-team).

`agentgolf harness managed-settings codex` prints the shared settings. Add `--endpoint <url>` for a Self-Hosted Uplink instance. See [`agentgolf harness managed-settings`](https://docs.agent.golf/cli/commands#agentgolf-harness-managed-settings). Put them in a managed layer. Do not put a publishing key in it:

```toml theme={null}
# /etc/codex/config.toml, or the MDM config_toml_base64 value
[otel]
log_user_prompt = true
metrics_exporter = "none"

[otel.exporter.otlp-http]
endpoint = "<endpoint>/v1/logs"
protocol = "binary"

[otel.trace_exporter.otlp-http]
endpoint = "<endpoint>/v1/traces"
protocol = "binary"
```

Each developer runs `agentgolf harness setup --all`, or `agentgolf harness setup --all --endpoint <url>` with the same URL for a Self-Hosted Uplink instance. The command writes the publishing key to their user file. With another endpoint in the user file, Codex sends to that endpoint, because the user file is above `/etc/codex/config.toml`. To write the file by hand, put only the publishing key in it:

```toml theme={null}
# ~/.codex/config.toml
[otel.exporter.otlp-http]
headers = { x-agentgolf-publishing-key = "<publishing-key>" }

[otel.trace_exporter.otlp-http]
headers = { x-agentgolf-publishing-key = "<publishing-key>" }
```

* In `/etc/codex/config.toml`, the settings are defaults. A developer can change each of them in their user file.
* The MDM value `config_toml_base64` is above the user file. It fixes each key that it sets, for example `endpoint` and `protocol`, and keeps the `headers` of each user, because the managed exporter tables have no `headers`.
* Never set `headers` in a managed layer. Under `config_toml_base64`, it replaces the personal publishing key of each user.
* Do not set `exporter` or `trace_exporter` in the `[otel]` table of a Codex `requirements.toml`, or of the MDM key `requirements_toml_base64`. A requirement replaces the full exporter, with its `headers`. It removes each developer's personal publishing key, and Agent Golf cannot find their sessions' [contributor](https://docs.agent.golf/dashboard/sessions.md#contributor).
* You can set the other `[otel]` keys as requirements, for example `log_user_prompt` and `metrics_exporter`.

## Session content

Codex sends tool arguments and tool output in its log events by default.

`log_user_prompt = true` adds prompt text. The settings above turn it on. Set it to `false` where your policy does not allow the uplink instance to receive that content. With less content, Agent Golf links fewer sessions to pull requests automatically. See [Session content](https://docs.agent.golf/harnesses/overview.md#session-content).

## TLS with a private CA

Each exporter accepts a `tls` table for the trust anchor of a private CA. See the [Codex configuration reference](https://developers.openai.com/codex/config-reference) for its keys.

## Known limits

* `codex mcp-server` sends no OpenTelemetry data. Sessions in this mode do not show in Agent Golf.

## Verify the setup

* Start `codex` and send a prompt. Then do the checks in [Verify the setup](https://docs.agent.golf/harnesses/overview.md#verify-the-setup).
* If Uplink receives no requests, confirm that `exporter` and `trace_exporter` are set in `~/.codex/config.toml` or in a managed layer.
* If Uplink refuses the requests, or sessions have no contributor, confirm that no Codex requirement sets `exporter` or `trace_exporter`. Codex writes a warning at start when a requirement replaces a setting.


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