Skip to content

Codex diff recovery finds nothing: codex-cli 0.163.0 records patches as FileChange items, not patch_apply_end #1085

Closed

Description

@JacobStephens2

Problem

Recovering Codex diffs (#988) found nothing on real data. In #994, converting thirdshift's Session logs reported codex_diffs: 0 across 297 Codex Sessions. 189 of those had file_change items and a matching Codex session file under ~/.codex/sessions.

Cause

src/harness/codex/patches.rs reads patch_apply_end records (the reference cited is openai/codex rust-v0.160.0, PatchApplyEndEvent). Its count must equal the Session's apply_patch edits, or it supplies nothing. The session files written by codex-cli 0.163.0, in use on the thirdshift host, have no patch_apply_end records. Their patches show up as:

  • response_item / custom_tool_call named exec, whose input calls tools.apply_patch(...);
  • event_msg / item_completed with item.type == "FileChange", whose changes map each absolute path to {type, unified_diff}.

For example, in rollout-2026-10-19T11-02-16-01a154af-…jsonl (clave #19 implement), the Session log has 6 file_change items and the Codex file has 6 FileChange items with unified diffs, but 0 patch_apply_end records. Because the reader stops whenever it finds no match, this produces no error.

The same Completion reader serves live Codex sessions, so live Session traces on current Codex are probably missing their diffs too.

Acceptance criteria

  • Diffs are recovered from FileChange item_completed records, keeping the patch_apply_end format as long as the supported Codex versions still need it.
  • A fake Codex session file in the current format gives diffs, in a live Session and in conversion.
  • Check whether the 0.147.0 Codex on stephens writes the old format, the new one, or both.

Part of #700, found in #994.

Activity

  1. added
    bug
    needs-triage
    on Oct 22, 2026
  2. added
    ready-for-agent
    and removed
    needs-triage
    on Oct 22, 2026
  3. JacobStephens2 commented on Oct 22, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Scope note for the agent: you won't have SSH access to stephens, so the third acceptance criterion (checking which format Codex 0.147.0 writes there) is for the Day shift, not this Run. Meet it in code by reading both patch_apply_end and FileChange item_completed records, with a fake Codex session file for each format. Never fail when neither is found. Key files: src/harness/codex/patches.rs (Completion::amendments, read), src/logs/convert.rs (where codex_diffs is counted), and the #988 tests that use the fake Codex file.

  4. added
    in-progress
    and removed
    ready-for-agent
    on Oct 22, 2026
  5. removed
    in-progress
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions