Codex plugin that sends OpenAI Codex session telemetry to Langfuse. It traces agent turns, model generations, reasoning summaries, system prompts, tool calls, images, subagent threads, skills, and token usage.
Langfuse also documents this integration on the Codex integration page.
Add the plugin marketplace:
codex plugin marketplace add langfuse/codex-observability-pluginThen enable hooks and the plugin in ~/.codex/config.toml, or only for one project in <project>/.codex/config.toml:
[features]
hooks = true
[plugins."tracing@codex-observability-plugin"]
enabled = trueRestart Codex after changing the config. When Hooks need review appears, review the Langfuse Stop hook in /hooks and trust it. An installed and enabled plugin is not yet a trusted hook, and no traces are uploaded before you trust it. Codex records trust against the current hook hash, so a plugin update can require another review.
- Codex
0.143and newer - Node.js
22and newer - The
npmCLI on yourPATH, which Codex uses to fetch the plugin from the npm registry - Langfuse Cloud, or self-hosted Langfuse
3.95.0and newer
Create ~/.codex/langfuse.json (global) or <project>/.codex/langfuse.json (per-project) with your Langfuse credentials.
{
"enabled": true,
"public_key": "pk-lf-...",
"secret_key": "sk-lf-...",
"base_url": "https://cloud.langfuse.com"
}Only enabled, public_key and secret_key are required. If base_url is not set, the plugin uses https://cloud.langfuse.com for the 🇪🇺 EU region. The other regions are https://us.cloud.langfuse.com (🇺🇸 US), https://jp.cloud.langfuse.com (🇯🇵 Japan) and https://hipaa.cloud.langfuse.com (⚕️ HIPAA).
You can also set credentials with environment variables:
export TRACE_TO_LANGFUSE="true"
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"Tracing stays off until enabled or TRACE_TO_LANGFUSE is true, so you opt in explicitly. Config is resolved as defaults, then ~/.codex/langfuse.json, then <project>/.codex/langfuse.json, then environment variables, and the environment wins. LANGFUSE_CODEX_* variables take precedence over the matching LANGFUSE_* ones, so you can scope credentials to Codex without disturbing other Langfuse tooling on the same machine.
The remaining options are settable both ways, as a langfuse.json key or as the matching LANGFUSE_CODEX_* variable:
environmentlabels the traces with an environment, for exampleproduction.user_idattaches a user to every trace. It defaults to the Codex auth email, if one is found.tagsadds your own tags to every trace, either as a JSON array or as a comma-separated list.metadataattaches a JSON object to every trace.skill_tagstags traces withskill:<name>for every skill invoked in the turn, and defaults totrue.trace_seedderives deterministic trace ids, so a headless caller knows a run's trace id up front. Use a unique seed per session.debuglogs verbosely to stderr, and defaults tofalse.fail_on_errorfails the hook on upload errors instead of failing open, and defaults tofalse.
Everything the plugin traces is uploaded to Langfuse, including prompts and tool inputs and outputs, so do not enable it for sessions containing data you do not want stored there.
See the contributing guide.