You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/autoloop.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -644,11 +644,11 @@ Examples:
644
644
### How It Works
645
645
646
646
1. On the **first accepted iteration**, the branch is created from the default branch.
647
-
2. On **subsequent iterations**, the agent checks out the existing branch and ensures it is up to date with the default branch (by merging the default branch into it).
647
+
2. On **subsequent iterations**, the agent checks out the existing branch and ensures it is up to date with the default branch. If the branch's changes have already been merged into the default branch (i.e., `git diff origin/main..autoloop/{program-name}` is empty), the branch is **reset to `origin/main`** to avoid stale commits. Otherwise, the default branch is merged into it.
648
648
3.**Accepted iterations** are committed and pushed to the branch. Each commit message references the GitHub Actions run URL.
649
649
4.**Rejected or errored iterations** do not commit — changes are discarded.
650
650
5. A **single draft PR** is created for the branch on the first accepted iteration. Future accepted iterations push additional commits to the same PR.
651
-
6. The branch may be **merged into the default branch** at any time (by a maintainer or CI). After merging, the branch continues to be used for future iterations — it is never deleted while the program is active.
651
+
6. The branch may be **merged into the default branch** at any time (by a maintainer or CI). After merging, the branch continues to be used for future iterations — it is never deleted while the program is active. On the next iteration, the branch is automatically reset to the default branch (see step 2) so that already-merged commits do not cause patch conflicts.
652
652
7. A **sync workflow** automatically merges the default branch into all active `autoloop/*` branches whenever the default branch changes, keeping them up to date.
653
653
654
654
### Cross-Linking
@@ -691,7 +691,10 @@ Each run executes **one iteration for the single selected program**:
691
691
692
692
### Step 3: Implement
693
693
694
-
1. Check out the program's long-running branch `autoloop/{program-name}`. If the branch does not yet exist, create it from the default branch. If it does exist, ensure it is up to date with the default branch (merge the default branch into it).
694
+
1. Check out the program's long-running branch `autoloop/{program-name}`. If the branch does not yet exist, create it from the default branch. If it does exist:
695
+
- Fetch the default branch: `git fetch origin main`.
696
+
- Check whether the branch's changes have already been merged into main. If `git diff origin/main..autoloop/{program-name}` produces no output (i.e., every change on the branch is already on main), the branch is stale — **reset it to `origin/main`**: `git reset --hard origin/main`.
697
+
- Otherwise, merge the default branch into the long-running branch to pick up any upstream changes.
695
698
2. Make the proposed changes to the target files only.
696
699
3.**Respect the program constraints**: do not modify files outside the target list.
Copy file name to clipboardExpand all lines: workflows/autoloop.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -759,11 +759,11 @@ Examples:
759
759
### How It Works
760
760
761
761
1. On the **first accepted iteration**, the branch is created from the default branch.
762
-
2. On **subsequent iterations**, the agent checks out the existing branch and ensures it is up to date with the default branch (by merging the default branch into it).
762
+
2. On **subsequent iterations**, the agent checks out the existing branch and ensures it is up to date with the default branch. If the branch's changes have already been merged into the default branch (i.e., `git diff origin/main..autoloop/{program-name}` is empty), the branch is **reset to `origin/main`** to avoid stale commits. Otherwise, the default branch is merged into it.
763
763
3.**Accepted iterations** are committed and pushed to the branch. Each commit message references the GitHub Actions run URL.
764
764
4.**Rejected or errored iterations** do not commit — changes are discarded.
765
765
5. A **single draft PR** is created for the branch on the first accepted iteration. Future accepted iterations push additional commits to the same PR.
766
-
6. The branch may be **merged into the default branch** at any time (by a maintainer or CI). After merging, the branch continues to be used for future iterations — it is never deleted while the program is active.
766
+
6. The branch may be **merged into the default branch** at any time (by a maintainer or CI). After merging, the branch continues to be used for future iterations — it is never deleted while the program is active. On the next iteration, the branch is automatically reset to the default branch (see step 2) so that already-merged commits do not cause patch conflicts.
767
767
7. A **sync workflow** automatically merges the default branch into all active `autoloop/*` branches whenever the default branch changes, keeping them up to date.
768
768
769
769
### Cross-Linking
@@ -806,7 +806,10 @@ Each run executes **one iteration for the single selected program**:
806
806
807
807
### Step 3: Implement
808
808
809
-
1. Check out the program's long-running branch `autoloop/{program-name}`. If the branch does not yet exist, create it from the default branch. If it does exist, ensure it is up to date with the default branch (merge the default branch into it).
809
+
1. Check out the program's long-running branch `autoloop/{program-name}`. If the branch does not yet exist, create it from the default branch. If it does exist:
810
+
- Fetch the default branch: `git fetch origin main`.
811
+
- Check whether the branch's changes have already been merged into main. If `git diff origin/main..autoloop/{program-name}` produces no output (i.e., every change on the branch is already on main), the branch is stale — **reset it to `origin/main`**: `git reset --hard origin/main`.
812
+
- Otherwise, merge the default branch into the long-running branch to pick up any upstream changes.
810
813
2. Make the proposed changes to the target files only.
811
814
3.**Respect the program constraints**: do not modify files outside the target list.
0 commit comments