Skip to content

fix(importer): set responseId on imported Codex entries (#508) - #701

Open
lis186 wants to merge 3 commits into
mainfrom
fix/codex-import-response-id
Open

lis186 wants to merge 3 commits into
mainfrom
fix/codex-import-response-id

Conversation

@lis186

@lis186 lis186 commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Summary

Imported Codex turns now carry responseId, so store.mergeByResponseId and the session-index _countedRids / _costByRid dedup apply to Codex imports (an overlapping re-import of the same response is one turn; count and cost are not doubled).

  • Codex 0.155+ rollouts persist a token_usage_record line (payload.response_id = upstream resp_…) just before the token_count it reports. parseCodexSessionFile attaches it only when the record's usage equals that token_count's last_token_usage, so a stray record cannot lend its id to another turn.
  • Entries without a matching record (older Codex, re-emitted token_counts) keep no key and the legacy id-based dedup.
  • Shape recorded in docs/wire-protocol-reference.md and the fix(importer): Codex entries never set responseId — proxy×import duplicates can never be deduped #508 investigation note; verified by key names and pairing counts only, no transcript content copied.
  • Scope: live Codex proxy entries still set no responseId (OpenAI HTTP/WS stay exempt per ADR 0012), so proxy×import merging remains the other half.

Fixes #508

Verification

  • Unit group (2 workers): 2075/2075 pass; importer test files: 112/112 pass (synthetic fixtures: re-import dedup, no-id legacy path, mismatched-usage record ignored).

Codex 0.155+ rollouts persist a token_usage_record line carrying the
upstream resp_… id just before the token_count it reports. The importer
attaches it as responseId when the record's usage equals that
token_count's last_token_usage, so store.mergeByResponseId and the
session-index _countedRids/_costByRid dedup apply to Codex imports.
Entries without a matching record keep no key and the legacy id dedup.
A legacy suffixed row without responseId still counts as the same turn
on rescan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T14:19:31.440157Z 579d3a0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

fix(importer): Codex entries never set responseId — proxy×import duplicates can never be deduped

1 participant