Skip to content

Fix multiple PRs opened for single autoloop program - #124

Merged
mrjf merged 4 commits into
mainfrom
copilot/fix-multiple-prs-autoloop
Apr 12, 2026
Merged

Fix multiple PRs opened for single autoloop program#124
mrjf merged 4 commits into
mainfrom
copilot/fix-multiple-prs-autoloop

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Autoloop creates a new PR with a hash-suffixed branch (e.g. autoloop/build-tsb-pandas-typescript-migration-480c452af2b58478) on every iteration instead of pushing to the existing PR. 20+ orphaned PRs accumulated for the same program.

Pre-step PR detection (autoloop.md)

The scheduling pre-step now queries the GitHub API for an existing open PR on the canonical branch before handing off to the agent:

pr_api_url = (
    f"https://api.github.com/repos/{repo}/pulls"
    f"?state=open&head={owner}:{head_branch}&per_page=5"
)

Outputs existing_pr (PR number or null) and head_branch (canonical name) in autoloop.json. Falls back to the state file's PR field if the API call fails.

Agent instructions (autoloop.md)

  • Step 1, Step 5, Reading Programs docs, and Common Mistakes all updated to reference existing_pr as the primary signal for whether to use push-to-pull-request-branch vs create-pull-request
  • The agent no longer needs to discover PRs itself — the pre-step provides the answer

Experiment log issue links (autoloop.md)

The experiment log issue body format now includes a prominent links table at the top showing Branch, Pull Request, Steering Issue, and State File — making each program's resources immediately discoverable from the long-running issue.

Stale branch filtering (sync-branches.md)

The sync workflow now skips branches matching -[0-9a-f]{16}$ (framework-generated hash suffixes), only syncing canonical autoloop/{name} branches. Prevents wasted merge work on dozens of orphaned branches.

Lock files

Recompiled via gh aw compile.

Copilot AI linked an issue Apr 12, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 12, 2026 12:05
…branches

The autoloop agent was creating new PRs with hash-suffixed branches on each
iteration instead of pushing to the existing PR. Root causes addressed:

1. Pre-step now detects existing open PRs for the selected program via the
   GitHub API and includes `existing_pr` and `head_branch` in autoloop.json.
   The agent no longer needs to discover PRs itself — the information is
   provided upfront.

2. Agent instructions updated to check `existing_pr` first and only call
   `create-pull-request` when no PR exists.

3. sync-branches.md now filters out stale branches with 16-char hex suffixes
   (created by the framework), only syncing canonical autoloop/{name} branches.

4. Lock files recompiled.

Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/61bed3ca-384f-49d2-8f81-d557fff66250

Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix multiple PRs opened for single autoloop program Fix multiple PRs opened for single autoloop program Apr 12, 2026
Copilot AI requested a review from mrjf April 12, 2026 12:08
Copilot finished work on behalf of mrjf April 12, 2026 12:08
@mrjf

mrjf commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

@copilot Can we store the existing branch and name open PR link in the long-running issue for each program, linked prominently at the top? That way we know exactly where to find it. Also, make it CONVENTIONAL, with the program name as the branch name, so it's always obvious (I thnk we do that already).

The experiment log issue body now includes a prominent links table at the
top showing Branch, Pull Request, Steering Issue, and State File. This
makes it immediately obvious where to find each program's resources.
Branch naming already follows the convention autoloop/{program-name}.

Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/f346c4f9-d6bc-43b6-829f-eda813c79831

Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Can we store the existing branch and name open PR link in the long-running issue for each program, linked prominently at the top? That way we know exactly where to find it. Also, make it CONV...

Done in d3d7f15. The experiment log issue body format now has a prominent links table at the top showing Branch, PR, Steering Issue, and State File — matching what the steering issue and status comment already had.

The branch naming is already conventional: always autoloop/{program-name} with no suffixes. The head_branch field in autoloop.json (added in this PR) reinforces that by providing the canonical name from the pre-step.

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.

Multiple PRs opened for single autoloop program

2 participants