[PR #6777] github: handle duplicate PR creation when agent creates PR #12099

Closed
opened 2026-02-16 18:17:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6777

State: closed
Merged: Yes


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6777 **State:** closed **Merged:** Yes --- 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
yindo added the pull-request label 2026-02-16 18:17:01 -05:00
yindo closed this issue 2026-02-16 18:17:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12099