Trace Codex CLI agent turns, tool calls, and API requests in Arize AX for full observability.Codex is OpenAI’s open-source CLI coding agent. The Arize Agent Kit instruments Codex notify hook events and exports OpenInference spans to Arize AX and/or Phoenix. Each agent turn is captured as an LLM span with tool calls, token usage, and API request details.
Launch Arize
To get started, sign up for a free Arize account and get your Space ID and API Key:- Log in at app.arize.com
- Click Settings and copy the Space ID
- Open the API Keys tab and create or copy an API key
Install
Curl installer (recommended)
Dedicated installer
Manual setup
- Set the notify hook in
~/.codex/config.toml:
- Create
~/.codex/arize-env.shwith your backend configuration (see Configuration below).
Configuration
All env vars go in~/.codex/arize-env.sh. The notify hook sources this file automatically.
Phoenix (self-hosted) — requires jq and curl, no Python:
opentelemetry-proto and grpcio:
Observe
Once tracing is enabled, Codex activity is streamed to Arize AX. You’ll see:- Turn traces — each agent turn (user prompt to assistant response) as a parent LLM span
- Tool call spans — one per tool decision and result pair
- API request spans — one per API or WebSocket request
- Session grouping — all turns from the same session grouped by
session.id - Token usage — prompt, completion, and total token counts on every turn span
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
ARIZE_TRACE_ENABLED | No | true | Enable or disable tracing |
ARIZE_API_KEY | For AX | - | Arize AX API key |
ARIZE_SPACE_ID | For AX | - | Arize AX space ID |
ARIZE_OTLP_ENDPOINT | No | otlp.arize.com:443 | OTLP gRPC endpoint (on-prem Arize) |
PHOENIX_ENDPOINT | For Phoenix | http://localhost:6006 | Phoenix collector URL |
PHOENIX_API_KEY | No | - | Phoenix API key (if auth enabled) |
ARIZE_PROJECT_NAME | No | Working dir basename | Project name in Arize/Phoenix |
ARIZE_USER_ID | No | - | User identifier added to all spans as user.id |
ARIZE_DRY_RUN | No | false | Print spans to log instead of sending |
ARIZE_VERBOSE | No | false | Enable verbose logging |
ARIZE_LOG_FILE | No | /tmp/arize-codex.log | Log file path (empty to disable) |
Troubleshooting
| Problem | Fix |
|---|---|
| Spans not appearing in Phoenix | Verify Phoenix is running (curl -s http://localhost:6006/healthz), check env vars in ~/.codex/arize-env.sh |
| Spans not appearing in Arize AX | Verify ARIZE_API_KEY and ARIZE_SPACE_ID in ~/.codex/arize-env.sh, ensure Python deps (python3 -c "import opentelemetry; import grpc") |
jq required error | Install jq: brew install jq (macOS) or apt-get install jq (Linux) |
| Session state issues | Remove stale state: rm -rf ~/.arize-codex/state_*.json |
| Want verbose logging | Set ARIZE_VERBOSE=true in ~/.codex/arize-env.sh |
| Want to test without sending | Set ARIZE_DRY_RUN=true and run Codex |