Repository navigation
Description
Problem
When preserve-branch-name: true is set and the target branch already exists on the remote, create_pull_request refuses to push:
Git push failed: Remote branch "autoloop/build-tsb-pandas-typescript-migration" already exists
and preserve-branch-name is enabled. Refusing to silently rename the branch.
This blocks workflows like autoloop where:
- The agent can't push directly (git credentials are cleaned before the agent step)
- The branch is long-lived and intentionally reused across iterations
- There's no open PR (previous one was merged), so the agent correctly calls
create_pull_requestrather thanpush_to_pull_request_branch
The handler falls back to creating an issue instead of a PR, which defeats the purpose.
Expected behavior
When preserve-branch-name is enabled and the named branch already exists on the remote, create_pull_request should force-push the patch to the existing branch and create the PR from it. The branch name matching is the point of preserve-branch-name — reusing the branch is the intended behavior, not a conflict.
Context
Autoloop maintains one long-lived branch per program (autoloop/{program-name}). Each iteration:
- Checks out the branch, merges main, commits new changes
- Needs to push to the branch (but can't — no git credentials during agent step)
- Calls
create_pull_requestto push via safe-outputs and create a PR
This works on the first iteration (branch doesn't exist yet). On subsequent iterations after a PR merge, the branch still exists on the remote but has no open PR. The agent calls create_pull_request again, which should push to the existing branch and open a new PR.
Example
- Failing run: https://github.com/githubnext/tsessebe/actions/runs/25117554579
- Program:
build-tsb-pandas-typescript-migration - Branch
autoloop/build-tsb-pandas-typescript-migrationexists (0 ahead, 99 behind main — fully merged) - No open PR
- Agent calls
create_pull_requestwithbranch: autoloop/build-tsb-pandas-typescript-migration - Handler refuses because branch exists → falls back to issue Parse agentic engine logs to extract exact Bash commands, tool usage etc. #242
Workaround
Manually delete the stale remote branches before each iteration. Not viable for automated loops.
Related
- create_pull_request patch uses stale origin/branchName instead of merge-base with default branch #28955 — stale patch base ref (fixed in v0.71.2)
- Count unique files in
create_pull_requestpatch limit and addmax-patch-filesconfig #28472 — max-patch-files config (shipped in v0.71.2)
Activity