opencode icon indicating copy to clipboard operation
opencode copied to clipboard

github: handle duplicate PR creation when agent creates PR

Open elithrar opened this issue 2 weeks ago • 3 comments

Fixes a false-negative workflow failure when the OpenCode agent creates a PR via gh pr create during its run - the post-run infrastructure then attempts to create a duplicate PR for the same branch, causing the workflow to fail with "A pull request already exists".

  • Check for existing open PRs with the same head→base combination before calling pulls.create (unique for any open PR)
  • Return the existing PR number if found, avoiding the duplicate PR error
  • Attempts to create the PR (no worse than existing behavior) if it cannot find a pull
  • a simple withRetry to retry the PR check and PR create API calls (net improvement)

Ref: https://github.com/elithrar/dotfiles/issues/19

elithrar avatar Jan 03 '26 21:01 elithrar