Skip to content

fix: skip in-progress Codex turn uploads#17

Open
honki12345 wants to merge 1 commit into
langfuse:mainfrom
honki12345:fix/skip-in-progress-turn-uploads
Open

fix: skip in-progress Codex turn uploads#17
honki12345 wants to merge 1 commit into
langfuse:mainfrom
honki12345:fix/skip-in-progress-turn-uploads

Conversation

@honki12345

Copy link
Copy Markdown

Summary

  • skip trailing in-progress Codex turns instead of exporting them before task_complete is written
  • keep completed-turn sidecar dedup behavior unchanged
  • add regression coverage for an in-progress trailing turn and update the README sidecar troubleshooting note

Why

The current behavior can create duplicate Langfuse traces for one Codex turn when the Stop hook reads the rollout before Codex has appended the task_complete marker. The first hook invocation exports a partial in-progress turn without recording it in the sidecar. A later Stop hook reads the completed turn and exports it again as a new trace.

Observed locally with v0.1.0 against a self-hosted Langfuse instance:

  • same metadata['codex.turn_id'] appeared with two distinct Langfuse trace_id values
  • both traces had the same turn start time
  • the first root observation ended just before the task_complete event
  • the second root observation ended at the task_complete timestamp

Example evidence shape:

turn_id: 019ef7e0-82fa-7f70-a011-139455607047
first trace end_time: 2026-06-24 04:32:41.352
second trace end_time: 2026-06-24 04:32:41.495
task_complete timestamp: 2026-06-24 04:32:41.495

This is related to the broader Stop hook / sidecar lifecycle concerns in #12, but this PR fixes the specific duplicate-trace path where an in-progress trailing turn is exported before completion.

Verification

  • pnpm exec prettier --check README.md plugins/tracing/src/trace.ts plugins/tracing/src/sidecar.ts plugins/tracing/test/trace.test.ts
  • pnpm run lint:tsc
  • pnpm run lint:dist
  • pnpm test

Note: an earlier parallel run of pnpm run lint:dist and pnpm test failed because lint:dist cleans/rebuilds plugins/tracing/dist/index.mjs while hook-command.test.ts copies that file. Running the commands sequentially passes.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants