Use this guide to observe local Codex CLI sessions and local Codex GUI or app sessions that honor the same local config and gateway routing. Cloud or remote Codex tasks are partial or unsupported for local gateway LLM capture because the local gateway cannot observe provider traffic that never reaches the machine.
codex-cli >= 0.129.0. The gateway uses the features.hooks flag and the
nemo-relay-openai provider alias, both of which require this version. Earlier
versions either reject the provider override or do not recognize the hooks
feature flag.
As of Codex 0.129, Codex requires hooks to be manually reviewed and activated before they run. Generated NeMo Relay hook configuration is not enough on its own if Codex leaves those hooks inactive. Review and activate the installed or injected hooks in Codex before expecting NeMo Relay events. This is being tracked upstream as openai/codex#21639.
Use the wrapper for no-install local observability:
Pass Codex arguments after --:
This shortcut is equivalent to nemo-relay run -- codex. The wrapper starts a
gateway on a dynamic 127.0.0.1 port, enables Codex hooks with CLI config
overrides, injects hook commands that use NEMO_RELAY_GATEWAY_URL, and points
Codex at a temporary nemo-relay-openai provider alias that uses the gateway
URL while preserving Codex’s OpenAI auth path.
Inspect what would be launched without starting Codex:
Create .nemo-relay/config.toml for project defaults or
~/.config/nemo-relay/config.toml for user defaults:
Then configure observability with nemo-relay plugins edit --project or
.nemo-relay/plugins.toml:
Run nemo-relay run --agent codex to use the configured command and plugin
config. User config takes priority over project and system config.
Use the long-running gateway only when you want Codex running outside the wrapper:
Then edit ~/.codex/config.toml and configure local Codex to use a gateway
provider alias instead of overriding the reserved built-in openai provider:
After saving the file, restart the Codex GUI or app so it reloads the provider
configuration. For CLI usage, start a new codex process.
Some Codex GUI or app versions appear to scope visible conversation history by
the active provider configuration. If existing conversations disappear after
switching model_provider to nemo-relay-openai, the history has not been
removed if it returns after restoring the previous provider configuration. Use
this standalone provider alias only while capturing gateway telemetry, or prefer
the transparent wrapper for CLI sessions. See the upstream Codex
history visibility discussion
for context.
Local Codex GUI or app sessions have the same support level only when they read the same local hook/plugin config and provider routing. Cloud tasks may still emit some lifecycle hooks, but complete LLM lifecycle capture requires model traffic to pass through the gateway.
Generated Codex hooks include SessionStart, SessionEnd, SubagentStart,
SubagentStop, PreToolUse, PostToolUse, PostToolUseFailure,
Notification, and PreCompact for scope, tool, and mark events.
UserPromptSubmit, AfterAgentResponse, AfterAgentThought, and Stop are
retained as private LLM correlation hints and are not emitted as standalone
NeMo Relay events.
The transparent wrapper passes hook entries as Codex CLI config overrides and
sets features.hooks=true for that launched process. Persistent install writes
.codex/config.toml with features.hooks = true and merges generated hook
entries into .codex/hooks.json.
Run a small Codex prompt that starts a session and uses one simple tool. Then check hook forwarding directly:
The response should match Codex hook semantics. For most lifecycle events it is an empty JSON object.
End the Codex session and confirm Agent Trajectory Interchange Format (ATIF) exists:
The gateway writes <session-id>.atif.json after every conversation turn for
Codex sessions (Codex’s hook surface has no SessionEnd-equivalent event, so
the gateway uses each per-turn Stop hook to snapshot the trajectory; the file
grows cumulatively across turns and the final write reflects the full session).
For agents that do emit a session-end hook, the same file is written once on
session close. If the file is missing, confirm features.hooks = true, hook
config loading, and that plugins.toml enables the ATIF exporter with a
writable output_directory.
If agent/tool events exist but LLM spans are missing, the active Codex provider is not pointing at the gateway for the active Codex process. If only GUI sessions are missing spans, confirm the GUI is using local provider configuration rather than a remote execution path.
If LLM spans exist but attach to the session instead of a subagent, pass
x-nemo-relay-subagent-id on gateway requests or include shared
conversation_id, generation_id, or request_id values in both hook payloads
and provider requests.