opencode
opencode copied to clipboard
github: handle duplicate PR creation when agent creates PR
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→basecombination before callingpulls.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
withRetryto retry the PR check and PR create API calls (net improvement)
Ref: https://github.com/elithrar/dotfiles/issues/19