Skip to content

fix(SESF-66): skip Codex external-import turns at ingest - #88

Merged
lbruton merged 1 commit into
mainfrom
fix/SESF-66-codex-import-skip
Oct 29, 2026
Merged

lbruton merged 1 commit into
mainfrom
fix/SESF-66-codex-import-skip

Conversation

@lbruton

@lbruton lbruton commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Part 1 of SESF-66. Part 2, which strips boilerplate tags at add_turns and cleans indexed rows, comes later in a separate PR.

Why

Codex Desktop imports Claude Code sessions into Codex rollouts. Each imported turn starts with a task_started event whose turn_id begins with external-import-. Those turns copy transcripts that are already indexed as claude_code_cli.

On the live index they were 47,355 of 103,185 FTS rows (46%), and they lead search results with [external_agent_tool_call: …] blocks. Content sampling against the claude_code_cli rows:

  • 214 import rollouts are on disk. 180 of them have comparable text.
  • 109 match on at least 75% of sampled messages, 65 match partly and 6 match none.
  • Every miss I checked has its original transcript on disk and indexed. The phrases are lost to max_turn_chars truncation, which SESF-62 tracks.

Change

  • provider_codex.CodexAdapter.parse_source tracks the current turn from task_started, because message items carry no turn id. It skips messages inside an import turn.
  • A native turn after an import in the same rollout is kept. One live rollout has this shape.
  • An imported user message is never paired with a native answer.
  • Gotcha entry in CLAUDE.md and AGENTS.md.

Cleanup plan (after merge and restart)

cleanup.py prune-codex deletes indexed Codex turns that a full parse of a rollout still on disk no longer produces, so it needs no new code. Dry runs against the live index:

Parser Turns parsed from disk Orphans to delete
main 42,418 0
this branch 437 27,254

Import turns of deleted rollouts are left alone: 26,454 rows in 59 sessions, each at least 60% import rows. 22 of those sessions have no overlap with the Claude Code index, so their originals may no longer be indexed. Deleting them could lose the only copy.

Tests

  • tests/test_provider_codex.py: an import-only rollout yields nothing, native turns after imports are kept, there is no cross-pairing, and a resumed parse still skips imports.
  • ruff check . is clean. pytest: 699 passed, 120 skipped.

Codex Desktop imports Claude Code sessions into rollouts. Their turns
start with a task_started event whose turn_id begins with
"external-import-", and they copy transcripts that are already indexed as
claude_code_cli. Measured on the live index, they were 47,355 of
103,185 FTS rows (46%), nearly all duplicates.

parse_source tracks the current turn from task_started and skips message
items inside an import turn. A native turn after an import in the same
rollout is kept, and an imported user message is never paired with a
native answer.

With this parser, cleanup.py prune-codex (dry run) finds 27,254 indexed
import turns whose rollout is still on disk. Import turns of deleted
rollouts (26,454 rows in 59 sessions) are left alone: 22 of those
sessions have no overlap with the Claude Code index.
@lbruton

lbruton commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 78e61b8 and 27c51d2.

Files selected for processing: 4
  • AGENTS.md
  • CLAUDE.md
  • provider_codex.py
  • tests/test_provider_codex.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

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 🔄 Running since 2026-10-29T14:07:34.933175Z 27c51d2 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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 1 minor

Results:
1 new issue

Category Results
CodeStyle 1 minor

View in Codacy

🟢 Metrics 13 complexity · 2 duplication

Metric Results
Complexity ✅ 13 (≤ 100 complexity)
Duplication ✅ 2 (≤ 5 duplication)

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@lbruton
lbruton merged commit e35b2ac into main Oct 29, 2026
9 checks passed
@lbruton
lbruton deleted the fix/SESF-66-codex-import-skip branch October 29, 2026 14:10
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.

1 participant