~/.codex/sessions/**/rollout-*.jsonl) to reconstruct spans. When a turn finishes, a Stop hook starts a detached collector, so Codex never waits on the network. Turns from the same Codex session share a conversation ID, so Agent Lens shows them as one conversation.
Prerequisites
- macOS or Linux. Windows isn’t supported.
- Node.js v20.6 or later.
- OpenAI Codex CLI with hooks and rollout logging enabled.
codex --ephemeralisn’t supported because it doesn’t write a rollout file. - A CoreWeave Forge account and Forge API key.
- An Agent Lens project (
[YOUR-TEAM]/[YOUR-PROJECT]) to receive traces.
Install the plugin
1
Install the package
This plugin is separate from the
weave-codex plugin documented in the Weave guide. Its package is @coreweave/forge-agent-lens-for-codex, and its command, environment variables, and settings directory use the forge-agent-lens-for-codex and FORGE_ names. If you installed weave-codex, run weave-codex uninstall and npm uninstall -g weave-codex before you install this plugin, so the two don’t send duplicate traces. Set FORGE_TRACE_PROJECT to the value you used for WEAVE_PROJECT. The plugin doesn’t read the weave-codex settings.2
Set your project and API key
Replace You can also run
[YOUR-TEAM]/[YOUR-PROJECT] with your Agent Lens project and [YOUR-API-KEY] with your API key, and then export them:wandb login instead of setting WANDB_API_KEY. For how the plugin resolves each setting, see Configuration reference.3
Install the Stop hook
~/.codex/hooks.json, backing up the original file once to hooks.json.bak. The command also skips your existing Codex sessions, so only turns you run after installation are sent to Agent Lens. To send that history deliberately, see Collect past sessions.4
Approve the hook in Codex
Codex doesn’t run newly added hooks until you approve them:
-
Open a terminal and run:
-
Inside the interactive Codex screen, not your shell, type:
- Under Stop Events, select the Forge Agent Lens hook, and then enable or trust it.
--dangerously-bypass-hook-trust flag.Run forge-agent-lens-for-codex status to confirm that the hook is installed and the plugin is ready.View Codex traces in Agent Lens
After running at least one Codex session, open your project in the Agent Lens UI:- Navigate to CoreWeave Forge, select Agent Lens from the product menu, and then select your project in the project selector at the top of the side menu.
- In the side menu, select Conversations.
- Select a conversation to inspect the full turn hierarchy.
Span timestamps come from the rollout file, so durations reflect actual execution time. A turn is sent once. If an export fails, the plugin retries that turn the next time the Stop hook fires.
Known limitations
- The
codex(interactive TUI) andcodex execcommands are supported.codex mcp, direct app-server or API sessions, and aborted turns that fire no Stop event aren’t covered. - A spawned subagent appears as a tool span only. Its separate rollout file isn’t reconstructed as a nested trace, so its own model calls and tool executions aren’t captured.
- Some
codex execenvironments don’t run the Stop hook. See Headless runs and explicit collection in the plugin README.
Configuration reference
This section lists the settings you can use to customize plugin behavior. State, settings, and the log file live in~/.forge-agent-lens-for-codex/, including settings.json and logs/collector.log. Set FORGE_CODEX_HOME only for isolated development or test environments.
Set
FORGE_CODEX_PROVIDER_NAME if Codex sends requests through a proxy or bridge to a different model provider. The plugin records the value on model spans.
Credential resolution order
The plugin never writes your API key tosettings.json. It looks for a key in this order:
- The
WANDB_API_KEYenvironment variable. - The
~/.netrcentry forapi.wandb.ai, or for the host inWANDB_BASE_URLif you set it.
settings.json, which takes precedence over the default.
The Forge SDK resolves the trace server and transport. For a custom deployment, set WANDB_BASE_URL, or set WF_TRACE_SERVER_URL to override the trace server explicitly.
Turn off content capture
SetFORGE_CODEX_INCLUDE_CONTENT=false to omit prompts, assistant output, reasoning, tool arguments and results, and the working directory. Spans keep model names, token usage, timing, tool names, call IDs, and MCP server names.
For interactive Stop-hook collection, set include_content to false in ~/.forge-agent-lens-for-codex/settings.json instead. A variable set only on the codex command may not reach hooks run by an already-running Codex app server, so the setting in the file is the reliable one. The environment of the hook process takes precedence over the settings file, so make sure that environment doesn’t set FORGE_CODEX_INCLUDE_CONTENT=true. If it’s unset, the plugin uses the value in settings.json. The environment variable is reliable for explicit forge-agent-lens-for-codex collect runs.
Collect past sessions
collect --all is an explicit backfill. It sends turns that haven’t been exported yet from every rollout session. A rollout without a cursor is read from the beginning, so this command can send history created before you installed the plugin:
--json to send JSON results.
Check plugin status
You can use this command to check plugin status or troubleshoot issues:--json for the same report as JSON.
If turns don’t appear in Agent Lens, check the collector log:
Troubleshooting
The following sections describe common issues and how to resolve them. The collector log at~/.forge-agent-lens-for-codex/logs/collector.log is the primary diagnostic source. The plugin always logs errors regardless of the debug setting.
No traces appear after running Codex
- Run
forge-agent-lens-for-codex status. If the last line readsnot ready, fix the reason it prints. - Confirm that the hook is installed and enabled. If you skipped the approval, run
codex, run/hooks, and enable the hook. - Confirm that
FORGE_TRACE_PROJECTis set to a validentity/projectslug, with exactly one/.statusprints the resolved project. - Confirm that an API key resolved.
statusreports whether one resolved, but not where it came from. If the plugin reads the wrong key, checkWANDB_API_KEYand~/.netrc. - Confirm that Codex isn’t running with
--ephemeral. That flag suppresses the rollout file the plugin reads. - If you upgraded the package or switched Node.js versions, run
forge-agent-lens-for-codex installagain. The hook records the Node.js and package paths it was installed with.
Turns appear but input and output text is empty
Content capture may be disabled. Check thatFORGE_CODEX_INCLUDE_CONTENT isn’t set to false and that include_content isn’t set to false in ~/.forge-agent-lens-for-codex/settings.json. status prints the resolved include content value.
Errors sending traces to Agent Lens
If the plugin is active and generates spans that don’t appear in Agent Lens, check the collector log for an export error and match it against this table.Upgrade the plugin
The hook records the Node.js and package paths it was installed with. To upgrade, or after switching Node.js versions, reinstall the package and runinstall again: