Skip to content

[#30]: handle apply_patch_end turn items from Codex v0.129.0#42

Merged
delexw merged 1 commit intomainfrom
fix-issue-30
May 10, 2026
Merged

[#30]: handle apply_patch_end turn items from Codex v0.129.0#42
delexw merged 1 commit intomainfrom
fix-issue-30

Conversation

@delexw
Copy link
Copy Markdown
Contributor

@delexw delexw commented May 10, 2026

Summary

Fixes #30

Codex v0.129.0 introduced two changes that affected how apply-patch results are stored in JSONL session files:

  • PR #20540: File change records from apply_patch tool calls moved out of the patch_apply_end event_msg and into a new apply_patch_end response_item (turn item).
  • PR #20463: EventMsg::ApplyPatchEnd is now explicitly stored in limited history mode, meaning a patch_apply_end event_msg may coexist with custom_tool_call_output in the same session — causing the old finalize_patch path to create a duplicate PatchApply tool call entry.

Changes

src-tauri/src/parser/toolcall.rs

  • Added backfill_patch_result() to ToolCallBuilder: finds an already-finalized PatchApply call by call_id and updates its patch_success and patch_changes fields without pushing a new entry. Used by both the new turn-item path and the late-arriving event path.
  • Updated finalize_patch() to detect when a call is already finalized by custom_tool_call_output and backfill rather than create a duplicate entry.

src-tauri/src/parser/turn.rs

  • Added "apply_patch_end" handler in handle_response_item(): reads call_id, success, and changes from the new v0.129.0 turn item and calls backfill_patch_result().

No new public types or API surface changes — the fix wires the new turn item type into the existing ToolCallBuilder infrastructure.

Backward Compatibility

Old-format sessions (pre-v0.129.0) that use custom_tool_call + patch_apply_end event with no custom_tool_call_output continue to finalize normally via the existing pending-call path in finalize_patch.

Tests

Three new tests in parser::turn::tests:

Test Covers
apply_patch_end_turn_item_backfills_file_changes_onto_finalized_call v0.129.0+ new turn item: verifies patch_success, patch_changes, status, single tool call
patch_apply_end_event_after_custom_tool_call_output_does_not_create_duplicate v0.129.0+ event dedup: verifies exactly one PatchApply entry, patch_changes backfilled
patch_apply_end_event_finalizes_pending_call_in_old_format Pre-v0.129.0 backward compat: event still finalizes pending call with changes and stdout

Verification

cargo test --lib  →  62 passed, 0 failed
npx vitest run    → 122 passed, 0 failed
cargo clippy      →   0 warnings
npx oxlint        →   0 warnings / errors
npx oxfmt --check →  all files correctly formatted
npx tsc --noEmit  →  no type errors

…0.129.0)

Codex v0.129.0 (PR #20540) moved apply-patch file change records out of
the patch_apply_end event_msg and into a new apply_patch_end response_item
(turn item). PR #20463 also made ApplyPatchEnd explicitly stored in limited
history mode, meaning patch_apply_end event_msgs may now coexist with
custom_tool_call_output in the same session.

Changes:
- Add backfill_patch_result() to ToolCallBuilder: updates patch_success and
  patch_changes on an already-finalized PatchApply call without creating a
  duplicate entry.
- Update finalize_patch() to call backfill_patch_result() when the call is
  already finalized, preventing duplicate PatchApply tool call entries in
  sessions recorded with v0.129.0+.
- Add apply_patch_end handler in handle_response_item() that backfills file
  change data from the new v0.129.0 turn item onto the finalized call.

Backward compatible: old-format sessions using custom_tool_call + patch_apply_end
event (no custom_tool_call_output) continue to finalize normally via the
existing pending-call path.

Fixes #30
@delexw delexw merged commit 3ebcdbc into main May 10, 2026
1 check passed
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.

[Compat] Codex v0.129.0: apply-patch file changes moved into turn items

1 participant