Skip to content

feat: add concurrency flag and optimize AI context for conflict resolution#469

Open
dataforxyz wants to merge 8 commits intoendorhq:mainfrom
dataforxyz:feat/merge-concurrency-optimizer
Open

feat: add concurrency flag and optimize AI context for conflict resolution#469
dataforxyz wants to merge 8 commits intoendorhq:mainfrom
dataforxyz:feat/merge-concurrency-optimizer

Conversation

@dataforxyz
Copy link
Contributor

Summary

  • Add --concurrency flag for parallel conflict resolution during merge/rebase
  • Optimize AI context sent to agents during conflict resolution to reduce token usage and improve accuracy

Stacked on #467 and #462.

Test plan

  • Run pnpm test to verify all tests pass
  • Test merge command with --concurrency flag
  • Verify context optimizer correctly extracts relevant context

🤖 Generated with Claude Code

dataforxyz and others added 7 commits January 29, 2026 15:41
Allow users to specify an AI agent with optional model for the merge
command (e.g., rover merge 1 -a claude:sonnet). All agent constructors
now accept an optional model parameter passed through to their CLI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a new `rover rebase` command that rebases a task's branch onto the
current branch. Includes AI-powered conflict resolution, automatic
commit of uncommitted worktree changes, and -a/--agent flag support.
Also adds rebaseBranch, abortRebase, and continueRebase methods to Git.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Stop silently swallowing errors in resolveMergeConflicts across all agent
implementations (claude, gemini, codex, cursor, qwen) so callers can
surface the actual failure reason. Also log errors in generateCommitMessage.

The resolve functions in merge.ts and rebase.ts now return
{ success, failureReason } instead of boolean, so the actual error
is surfaced in both spinner output and --json mode.

Closes endorhq#464

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolve conflicted files in parallel during merge/rebase instead of
sequentially. Defaults to 4 concurrent AI resolutions. Collects all
failures instead of stopping at the first error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Send only relevant context (50 lines around each conflict region) and
blame-based commit history instead of full file content. Adds
--context-lines and --send-full-file flags to merge and rebase commands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tream changes

After rover rebase, task.baseCommit pointed to the original commit from
worktree creation. This caused rover diff --base to include upstream
changes in the diff. Now we update baseCommit to the current branch HEAD
after a successful rebase.

Fixes endorhq#476

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allow programmatic consumption of diff output by adding JSON format
support to the `rover diff` command, consistent with other commands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Collaborator

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think this is an interesting approach! Just to split my comments:

  • Concurrency: I'm in general fine with it, the only comment I have is whether --concurrency might sound like a misplaced argument for merge and rebase; we might want to configure concurrency in general per agent/model, and these commands just use it if it's configured, or maybe use an envvar (although envvars are not easy to discover in general).

  • Conflict context: although I think the idea is great in order to optimize the context that the agent sends to the model, I'm wondering if in order to fix some conflicts, the agent requires the whole context (e.g. I'm thinking about conflicts that somehow involve imports that might be out of the context and at the beginning of the file). In principle this makes a lot of sense, but it would be great to have a way to test it. We can add the optimization strategy as an opt-in functionality with a flag, so we can experiment with it.

This also needs to be rebased on top of #467 after it gets merged.

@ereslibre ereslibre self-assigned this Jan 30, 2026
When truncateConflictContext() sends a truncated file to the AI, the AI
returns only the visible portion. writeFileSync then overwrites the full
file with this partial content, destroying omitted lines.

Use region-based resolution: ask the AI to return only resolved conflict
regions using ---REGION N--- markers, then splice them back into the
original file. Falls back to full-file resolution if parsing fails.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dataforxyz dataforxyz force-pushed the feat/merge-concurrency-optimizer branch from acbb45c to 212be1f Compare January 30, 2026 23:57
@dataforxyz
Copy link
Contributor Author

Added: Region-based conflict resolution to prevent file truncation

Problem: When truncateConflictContext() sends a truncated file to the AI (default mode), the AI returns only the visible portion. writeFileSync then overwrites the full file with this partial content, destroying omitted lines (e.g., 214-line file → 70 lines).

Fix: Instead of asking the AI to return the entire file, we now ask it to return only the resolved conflict regions using ---REGION N--- markers, then splice them back into the original file via reconstructFile(). Falls back to full-file resolution if region parsing fails.

Changes:

  • New prompt template resolve-merge-conflicts-regions.md for region-based output format
  • parseResolvedRegions() and reconstructFile() in context-optimizer.ts
  • resolveMergeConflictsRegions() added to all AI agent implementations
  • Both merge.ts and rebase.ts updated to use region-based resolution in truncated mode
  • Tests for parsing, reconstruction, and full round-trip integration

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