Add Langfuse Tracing Integration in Codex CLI
Open 💬 10 comments Opened Jul 29, 2025 by ShashankDatt08
I'd like to propose an enhancement to the Codex CLI that enables Langfuse tracing for better observability during code generation and execution.
Summary:
I would like to propose a feature to integrate Langfuse with the Codex CLI to enable structured tracing and observability of local executions.
This would allow users to capture useful metadata and performance data around Codex CLI runs including input prompts, outputs, and timestamps — which can significantly improve debugging, auditing, and understanding of generated code.
Motivation:
We are actively using the Codex CLI in automated developer workflows at Infinite Computer Solutions, and found that adding Langfuse instrumentation allows us to:
- Track the lifecycle of each
codex execcall - Correlate Git operations with Codex outputs
- Monitor performance and failures in an LLM-powered dev agent
Proposed Implementation:
from langfuse._client.get_client import get_client
Initialize Langfuse client
langfuse_client = get_client()
Wrap script in Langfuse span:
- with langfuse_client.start_as_current_span(name="local_agent_script", input={"repo_url": args.repo_url, "branch": args.branch, "prompt": args.prompt}) as span:
...
span.update(output={"codex_output": codex_output, "commit_message": commit_message})
Company Context:
This feature would help us and other enterprise teams building AI developer tools powered by Codex.
We're currently experimenting with this setup at Infinite Computer Solutions, and would love to contribute or collaborate if this sounds useful.
10 Comments
Thanks Seratch for tagging this as an enhancement
Just to add some context from our side , we’ve already started experimenting with wrapping codex exec in Langfuse spans locally, and the results have been very promising. A couple of specific benefits we’ve seen:
End-to-end traceability: Being able to connect a Codex CLI run with Git operations and downstream automation helps a lot in debugging agent workflows.
Performance insights: With Langfuse metrics, we can easily spot latency spikes or repeated failures across multiple runs.
Auditability: In enterprise setups (like ours at Infinite Computer Solutions), having structured logs of prompts, outputs, and commit metadata is critical for compliance and reviews.
Proposed Integration
We’d love to collaborate on a minimal integration approach that:
Would the maintainers be open to a draft PR exploring this integration?
is it done yet?
Yes, it’s done!
You can refer to the screenshot below showing how the Langfuse tracing looks after the integration:
<img width="1661" height="833" alt="Image" src="https://github.com/user-attachments/assets/bd470626-b07b-4225-aa0b-33ce48f30781" />
@seratch — let me know when would be a good time to discuss integrating this upstream. I’d be happy to open a draft PR or walk through the changes.
I know the latest comment was only 5 days ago :) , but any idea when this will be upstreamed? Very interested in getting my hands on this! Very useful feature!
@ShashankDatt08 can you share a bit on the idea? How you achieved this integration, very interested in knowing this thanks!
<img width="1261" height="788" alt="Image" src="https://github.com/user-attachments/assets/8744e797-fd3a-483e-b553-fdcc04a4ade3" />
<img width="1078" height="835" alt="Image" src="https://github.com/user-attachments/assets/53bc5a4c-2b32-447b-a42a-864beda5708c" />
Session ~
I will release it in about half a month.
I'm able to send logs from Codex directly to Otel collector through https://github.com/aperoc/codex-plus, which can then be forwarded to Langfuse.
@n-WN, looks awesome!
any update?I need this please!
I want to know what the maintainers think. I'm in favor of this feat being merged @celia-oai