> For the complete documentation index, see [llms.txt](https://krynix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krynix.gitbook.io/docs/connect-your-agents/connect-codex.md). Agents can also search and read this documentation through its [MCP server](https://krynix.gitbook.io/docs/~gitbook/mcp).

# Codex

Codex has no HTTP hooks, so its install keeps a small hook script on the machine. Krynix generates **two managed files and one environment line**; Codex reads the files above every user and project setting, and the hook runs before each tool call. Enforcement holds the same way as for Claude Code: the hook asks Krynix, and a deny blocks the call.

macOS and Linux only. Codex ignores its managed configuration on Windows, so the telemetry could only go in a file a developer can override; Krynix refuses to generate a Windows install rather than ship one that does not hold.

## 1. Create the install

On the agent's page, open **Connect with Claude Code** and choose the **Codex** tab. Codex is delivered by **your device management** or **Just this machine** (one command, run as an administrator on the machine, which installs everything below and creates the key there; see [Connect Claude Code](https://krynix.gitbook.io/docs/connect-your-agents/connect-claude-code.md)). Besides the two choices shared with Claude Code (what to do when Krynix can't be reached, whether to capture prompt text), device management needs:

* **Operating system**: macOS or Linux. It fixes where the files go.
* **Where `node` is installed**: an absolute path, such as `/opt/homebrew/bin/node` or `/usr/bin/node`. A bare `node` is refused, because it would resolve through a `PATH` the developer controls.

Press **Create install**. (Just this machine finds `node` and the operating system itself and asks for neither; it shows one command to run, as for Claude Code.)

For device management, Krynix creates a key named for this install and shows, in order:

1. **Download krynix-hook.mjs**, with the script's SHA-256 so you can check the file before you deliver it (`shasum -a 256 krynix-hook.mjs`).
2. **Copy requirements**: the hook file.
3. **Copy managed config**: the telemetry file.
4. **Copy environment**: the one environment line.

The key is inside the files and shown once; copy them now.

## 2. Put the files in place

Both files need root.

| File                             | What it holds                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/etc/codex/requirements.toml`   | The hook: `[features] hooks = true`, the managed hook directory, and a `PreToolUse` and `PostToolUse` command that runs the Krynix hook script with your key, agent id, and outage setting. Hooks here are trusted by policy; a developer's own hooks need their trust and can be disabled, these cannot. "Only allow hooks your organisation manages" adds `allow_managed_hooks_only = true`. |
| `/etc/codex/managed_config.toml` | The `[otel]` logs exporter pointed at Krynix with the key, and `log_user_prompt` set from your prompt-capture choice. This is Codex's highest configuration layer.                                                                                                                                                                                                                             |
| the hook script                  | `/Library/Application Support/Krynix/krynix-hook.mjs` on macOS, `/opt/krynix/krynix-hook.mjs` on Linux. Admin-owned. Download it from the connect page, which shows its SHA-256 so you can check the file you deliver.                                                                                                                                                                         |

Then the environment line, set wherever Codex is launched:

```
OTEL_RESOURCE_ATTRIBUTES=agent.id=<your agent id>
```

No managed file can set an environment variable, and Codex names its telemetry resource only from this one. Without it, Codex's logs arrive under the process name rather than your agent.

## 3. Check one machine

Run Codex and ask it for a command your policy denies. It is refused with the rule's reason, and the session appears in the dashboard with the hook's records and Codex's own telemetry under one agent.

## What this does not cover

* **A developer controls the shell Codex runs the hook in**, and can keep it from running. Krynix makes that visible rather than pretending otherwise: the hook sends each call's id with its decision request, and a Codex `exec_command` or `apply_patch` call that no decision covered is reported as an **unjudged call** finding (high severity) on any session that holds a decision or belongs to an agent declared enforced.
* **The hook keeps a spool.** Unlike the Claude Code HTTP hook, a capture made while Krynix is unreachable is written to disk (`~/.krynix/hook-spool` by default) and sent when Krynix is back. Nothing undelivered is deleted.
* **A failed `codex exec` run exits before its logs are exported**, so Krynix receives nothing for it. A long-lived Codex app server or the interactive TUI exports normally.
* **Cost is a floor.** Codex prices each turn itself and only while its process is running. Krynix adds every priced turn; a spend ceiling the sum already exceeds fails, one it merely satisfies is unknown.
* **Windows is not supported** for the managed install.
