fix: wire tracing provider and parse Codex user messages - #52
Open
idityaGE wants to merge 1 commit into
Open
Conversation
Author
|
Reviewer notes: the main thing worth scrutinizing is the provider-wiring regression test. I kept it intentionally small because this plugin bundles the hook and a behavioral unit test around the global OpenTelemetry provider would be more brittle, but the source invariant is less strong than a full runtime assertion. Also worth double-checking whether there are any other Codex wrapper message shapes beyond |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two tracing correctness issues in the Codex plugin:
NodeTracerProvider, so spans created through@langfuse/tracingare exported by the configured Langfuse span processor.item_completedUserMessageevents are now preferred when extracting the user prompt, and instruction-wrapper content is ignored as a fallback.Fixes #51.
Fixes #47.
Why
Codex 0.147 writes the real user prompt as an
item_completedevent withitem.type === "UserMessage". The previous parser could fall back to wrapper content such asAGENTS.md,<environment_context>, or<user_instructions>, which made the Langfuse trace input misleading.Separately, the plugin registered its own OpenTelemetry provider but did not pass it to
@langfuse/tracing. That meant Langfuse observations could be created against the global provider instead of the provider that owns the Langfuse exporter.Changes
setLangfuseTracerProvider(provider)after registering the plugin'sNodeTracerProvider.event_msg.payload.type === "item_completed"anditem.type === "UserMessage".AGENTS.md,<environment_context>, and<user_instructions>content as instruction wrappers instead of user prompts.dist/index.mjsbundle.Testing
npx pnpm run formatnpx pnpm testnpx pnpm run lint:tscnpx pnpm run lint:distManual verification
Tested with a local Langfuse Docker stack and a project-level Codex plugin config. A real Codex run from
/tmp/codex-plugin-testuploaded a trace to Langfuse with:Codex Turnlocal-codex-plugin-testcodex-plugin-testList the files in this directory, read sample.txt, and summarize it in one sentence.LLM,exec_command,exec_command,LLMScreenshot: