fix: stage agent-resolved conflicts before checking unmerged files - #168
Merged
jeremymcs merged 2 commits intoAug 18, 2026
Merged
Conversation
jeremymcs
force-pushed
the
codex/fix-conflict-resolution-staging
branch
from
August 18, 2026 08:29
c01f691 to
40d01da
Compare
Owner
|
Rebased onto This branch carried four commits that Verified locally: Note: #167 also touches |
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.
Problem
When a tracked PR has merge conflicts, the conflict-resolution agent often resolves the files in the worktree without staging them (
git add). PatchDeck then checks for unresolved conflicts withgit diff --name-only --diff-filter=U, which reads the index's unmerged state — not the worktree content. So fully-resolved files still show as unmerged and the run is falsely declared failed withcodex left unresolved merge conflicts: <files>, then falls into the code-owner fallback path. The resolution is never committed or pushed, so GitHub keeps showing "This branch has conflicts that must be resolved" forever.Observed in production on PR cwbcheng/OpenAgent#433: the agent reported "All merge conflicts have been resolved … nothing staged/committed", then PatchDeck logged
PR work error: codex left unresolved merge conflicts: tools/novelstudio/embodied-agent-runtime-control/src/contract-shapes.mjs …and the three conflict files stayed unresolved on GitHub.Fix
After the conflict-resolution agent completes successfully, stage everything in the worktree (
git add -A) before the unmerged-index check. If the agent actually left conflict markers behind, the existing marker check (git grepfor<<<<<<<etc.) still catches them and fails with the more accurate "left merge conflict markers" reason, so genuinely-broken resolutions are still escalated.Tests
babysitPR commits agent-resolved conflicts even when the agent does not stage them. It simulates the agent editing the conflicted file without staging: the unmerged index check only clears after PatchDeck runsgit add. Fails without the fix (run fails with "left unresolved merge conflicts").node --import tsx --test server/babysitter.test.ts(111 tests pass),npm run checkpasses.