Skip to content

fix: stage agent-resolved conflicts before checking unmerged files - #168

Merged
jeremymcs merged 2 commits into
jeremymcs:mainfrom
cwbcheng:codex/fix-conflict-resolution-staging
Aug 18, 2026
Merged

fix: stage agent-resolved conflicts before checking unmerged files#168
jeremymcs merged 2 commits into
jeremymcs:mainfrom
cwbcheng:codex/fix-conflict-resolution-staging

Conversation

@cwbcheng

@cwbcheng cwbcheng commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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 with git 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 with codex 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 grep for <<<<<<< etc.) still catches them and fails with the more accurate "left merge conflict markers" reason, so genuinely-broken resolutions are still escalated.

Tests

  • Added regression test 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 runs git add. Fails without the fix (run fails with "left unresolved merge conflicts").
  • Verified: node --import tsx --test server/babysitter.test.ts (111 tests pass), npm run check passes.

@jeremymcs
jeremymcs force-pushed the codex/fix-conflict-resolution-staging branch from c01f691 to 40d01da Compare August 18, 2026 08:29
@jeremymcs

Copy link
Copy Markdown
Owner

Rebased onto main to clear the conflict.

This branch carried four commits that main had already landed separately through #163/#164/#165, and those duplicates were the source of the conflict. The branch is now just your unique commit (stage agent-resolved conflicts before checking unmerged files) on top of current main; it cherry-picked cleanly with no content conflict.

Verified locally: npm run check, npm run test:all (789 tests), npx eslint . — all green.

Note: #167 also touches babysitter.ts. Whichever of the two merges second may need a small rebase.

@jeremymcs
jeremymcs merged commit 5fc4fbc into jeremymcs:main Aug 18, 2026
8 checks 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.

2 participants