fix(route): resume existing ai/issue-N branch on re-trigger #47

Merged
ffaerber merged 1 commits from fix/route-resume-existing-branch into main 2026-07-04 12:21:08 +02:00
Owner

Bug

Re-triggering an agent on an issue that already has a branch/open PR silently lost the new work. route.sh handled a comment-on-issue by git checkout -b ai/issue-N on a fresh clone of main, so the push back was rejected non-fast-forward and swallowed by || true. The run still reported success and publish.sh re-announced the pre-existing PR — so it looked like nothing happened and no new PR appeared. Observed on issue #17 run #88 (log: ! [rejected] HEAD -> ai/issue-17 (non-fast-forward)).

Fix

When the ai/issue-N branch already exists, resume it (fetch + checkout) so new commits fast-forward onto the same branch and update its PR. Only branch from main when none exists. This mirrors the resume path already used for comments on a PR.

Verified with a local git simulation: branch-exists -> resumes with prior commits present; branch-absent -> new branch from main.

## Bug Re-triggering an agent on an issue that already has a branch/open PR silently lost the new work. `route.sh` handled a comment-on-issue by `git checkout -b ai/issue-N` on a fresh clone of main, so the push back was rejected **non-fast-forward** and swallowed by `|| true`. The run still reported success and `publish.sh` re-announced the pre-existing PR — so it looked like nothing happened and no new PR appeared. Observed on issue #17 run #88 (log: `! [rejected] HEAD -> ai/issue-17 (non-fast-forward)`). ## Fix When the `ai/issue-N` branch already exists, **resume** it (fetch + checkout) so new commits fast-forward onto the same branch and update its PR. Only branch from main when none exists. This mirrors the resume path already used for comments on a PR. Verified with a local git simulation: branch-exists -> resumes with prior commits present; branch-absent -> new branch from main.
ffaerber added 1 commit 2026-07-04 12:21:06 +02:00
When an agent was re-triggered on an issue that already had a branch/open PR, route.sh created a
fresh branch from main (git checkout -b), so the push back was rejected non-fast-forward and the new
commits were silently dropped (|| true) -- the run reported success and re-announced the stale PR,
but the work was gone (observed on issue #17 run #88). Resume the existing branch when it exists, so
new commits fast-forward onto it and update its PR; only branch from main when none exists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ffaerber merged commit a1ff1b9881 into main 2026-07-04 12:21:08 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea/agents#47