Summary
On Codex CLI 0.147.0, the exported trace's input is the injected instructions / environment_context wrapper rather than the user's actual message. output is correct.
Both of the paths in parse.ts that resolve the user's turn miss on this CLI version, so the wrapper ends up in input and the real prompt is never read.
Reproduction
- Install plugin
tracing@0.1.0 with Codex CLI 0.147.0.
- Start a Codex session in a repository that has an
AGENTS.md.
- Send a short prompt, for example:
hi from codex. say "Hi"
- Open the resulting trace in Langfuse.
Expected: input is hi from codex. say "Hi"
Actual: input is ~14,000 characters beginning with # AGENTS.md instructions for <path> and ending with </environment_context>. The prompt does not appear anywhere in the trace. output is correct.
Root cause
The rollout for that single turn contains, in order:
- row 2 —
response_item, payload.type: message, role developer — the instructions
- row 3 —
response_item, payload.type: message, role user — the injected wrapper (this is what gets exported as input)
- row 6 —
response_item, payload.type: message, role user — the real prompt
- row 7 —
event_msg, payload.type: item_completed — carries item.type: "UserMessage" with item.content[].text
1. The primary path never matches
parse.ts:304:
if (et === "user_message" && typeof p.message === "string") {
Codex 0.147.0 emits no event_msg with payload.type === "user_message". The prompt arrives instead as item_completed carrying an item.type === "UserMessage" with item.content[].text (row 7 above).
So turn.userInput is never set, and parse.ts:150 falls through to userInputFallback.
2. The fallback then selects the wrapper
parse.ts:210:
!/^<(environment_context|user_instructions)/.test(text.trim())
The wrapper message is no longer prefixed with <environment_context>. On 0.147.0 it begins with # AGENTS.md instructions for <path> and only ends with </environment_context>, so this anchored test fails and the wrapper is accepted as the fallback.
The !turn.userInputFallback guard on the line above then prevents the real prompt (row 6) from ever replacing it.
Suggested fix
Two changes, both needed independently:
- Handle
item_completed with item.type === "UserMessage", reading item.content[].text, as a primary source for turn.userInput.
- Make the wrapper test content-based rather than prefix-anchored — detect an
<environment_context> / <user_instructions> element anywhere in the message, or skip any user message that also carries an instructions preamble.
Fixing only the regex leaves the fallback in use, which stays fragile across CLI versions.
Environment
- Plugin
tracing@0.1.0
codex-cli 0.147.0
- macOS, Node via Homebrew
Traces are otherwise delivered correctly — masking, token usage and the 20,000-character cap all behave as expected. Only the input mapping is affected.
Possibly related
#12 ("some completed Codex sessions produce no sidecar") may share a root cause in rollout parsing, though I have not confirmed that.
Summary
On Codex CLI
0.147.0, the exported trace'sinputis the injected instructions /environment_contextwrapper rather than the user's actual message.outputis correct.Both of the paths in
parse.tsthat resolve the user's turn miss on this CLI version, so the wrapper ends up ininputand the real prompt is never read.Reproduction
tracing@0.1.0with Codex CLI0.147.0.AGENTS.md.hi from codex. say "Hi"Expected:
inputishi from codex. say "Hi"Actual:
inputis ~14,000 characters beginning with# AGENTS.md instructions for <path>and ending with</environment_context>. The prompt does not appear anywhere in the trace.outputis correct.Root cause
The rollout for that single turn contains, in order:
response_item,payload.type: message, roledeveloper— the instructionsresponse_item,payload.type: message, roleuser— the injected wrapper (this is what gets exported asinput)response_item,payload.type: message, roleuser— the real promptevent_msg,payload.type: item_completed— carriesitem.type: "UserMessage"withitem.content[].text1. The primary path never matches
parse.ts:304:Codex
0.147.0emits noevent_msgwithpayload.type === "user_message". The prompt arrives instead asitem_completedcarrying anitem.type === "UserMessage"withitem.content[].text(row 7 above).So
turn.userInputis never set, andparse.ts:150falls through touserInputFallback.2. The fallback then selects the wrapper
parse.ts:210:The wrapper message is no longer prefixed with
<environment_context>. On0.147.0it begins with# AGENTS.md instructions for <path>and only ends with</environment_context>, so this anchored test fails and the wrapper is accepted as the fallback.The
!turn.userInputFallbackguard on the line above then prevents the real prompt (row 6) from ever replacing it.Suggested fix
Two changes, both needed independently:
item_completedwithitem.type === "UserMessage", readingitem.content[].text, as a primary source forturn.userInput.<environment_context>/<user_instructions>element anywhere in the message, or skip anyusermessage that also carries an instructions preamble.Fixing only the regex leaves the fallback in use, which stays fragile across CLI versions.
Environment
tracing@0.1.0codex-cli 0.147.0Traces are otherwise delivered correctly — masking, token usage and the 20,000-character cap all behave as expected. Only the input mapping is affected.
Possibly related
#12 ("some completed Codex sessions produce no sidecar") may share a root cause in rollout parsing, though I have not confirmed that.