[#30]: handle apply_patch_end turn items from Codex v0.129.0#42
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #30
Codex v0.129.0 introduced two changes that affected how apply-patch results are stored in JSONL session files:
apply_patchtool calls moved out of thepatch_apply_endevent_msg and into a newapply_patch_endresponse_item (turn item).EventMsg::ApplyPatchEndis now explicitly stored in limited history mode, meaning apatch_apply_endevent_msg may coexist withcustom_tool_call_outputin the same session — causing the oldfinalize_patchpath to create a duplicatePatchApplytool call entry.Changes
src-tauri/src/parser/toolcall.rsbackfill_patch_result()toToolCallBuilder: finds an already-finalizedPatchApplycall bycall_idand updates itspatch_successandpatch_changesfields without pushing a new entry. Used by both the new turn-item path and the late-arriving event path.finalize_patch()to detect when a call is already finalized bycustom_tool_call_outputand backfill rather than create a duplicate entry.src-tauri/src/parser/turn.rs"apply_patch_end"handler inhandle_response_item(): readscall_id,success, andchangesfrom the new v0.129.0 turn item and callsbackfill_patch_result().No new public types or API surface changes — the fix wires the new turn item type into the existing
ToolCallBuilderinfrastructure.Backward Compatibility
Old-format sessions (pre-v0.129.0) that use
custom_tool_call+patch_apply_endevent with nocustom_tool_call_outputcontinue to finalize normally via the existing pending-call path infinalize_patch.Tests
Three new tests in
parser::turn::tests:apply_patch_end_turn_item_backfills_file_changes_onto_finalized_callpatch_success,patch_changes,status, single tool callpatch_apply_end_event_after_custom_tool_call_output_does_not_create_duplicatePatchApplyentry,patch_changesbackfilledpatch_apply_end_event_finalizes_pending_call_in_old_formatchangesandstdoutVerification