Skip to content

feat: AI-powered conflict resolution for auto cherry-pick #1022

@myakove

Description

@myakove

Summary

Enhance the auto cherry-pick feature to use the AI CLI to automatically resolve merge conflicts when they occur during cherry-pick operations.

Problem / Motivation

When auto cherry-pick encounters merge conflicts, it currently fails and posts a "Manual cherry-pick is needed" comment with manual instructions. This requires the user to manually resolve conflicts locally, which is time-consuming.

Requirements

  1. AI conflict resolution: When git cherry-pick fails due to conflicts, invoke the AI CLI to resolve them
  2. Upstream-first strategy: The AI must prioritize upstream (target branch) changes first, then apply the current PR changes on top. This ensures the target branch's state is respected as the baseline
  3. No auto-verify for AI-resolved cherry-picks: When conflicts were resolved by AI, the resulting cherry-picked PR must NOT be automatically verified. The user must manually test and verify the cherry-pick is correct and working
  4. Fallback to manual: If AI fails to resolve conflicts, fall back to the current behavior (post manual cherry-pick instructions)

Implementation Notes

  • The cherry-pick method is in webhook_server/libs/handlers/runner_handler.py (method cherry_pick, line ~689)
  • AI CLI wrapper is in webhook_server/libs/ai_cli.py (call_ai_cli, get_ai_config)
  • The auto-verify-cherry-picked-prs config already exists in the schema and controls auto-verification
  • The _process_verified_for_update_or_new_pull_request method in pull_request_handler.py already checks auto_verify_cherry_picked_prs flag
  • AI features config (ai-features with ai-provider and ai-model) is required for this feature to work
  • When AI resolves conflicts, the cherry-picked PR comment should indicate that conflicts were resolved by AI and manual verification is required

Behavior Matrix

Scenario Cherry-pick PR auto-verified? Comment on PR
No conflicts Yes (existing behavior, respects auto-verify-cherry-picked-prs config) Standard cherry-pick success
Conflicts + AI resolved No (never auto-verify) AI resolved conflicts, manual verification required
Conflicts + AI failed N/A (no PR created) Manual cherry-pick instructions (existing behavior)
Conflicts + AI not configured N/A (no PR created) Manual cherry-pick instructions (existing behavior)

Deliverables

  • Detect cherry-pick conflicts in runner_handler.py
  • Call AI CLI to resolve conflicts with upstream-first prompt
  • Mark AI-resolved cherry-pick PRs so they are NOT auto-verified
  • Add informative PR comment when AI resolves conflicts
  • Fall back to manual instructions if AI resolution fails
  • Add tests for the new conflict resolution flow
  • Update configuration documentation if needed

Notes

  • AI features config (ai-features with ai-provider and ai-model) must be configured for this feature to activate
  • Without AI config, behavior remains unchanged (manual cherry-pick instructions on conflict)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions