Problem
The safe-outputs MCP server determines the base branch by running git rev-parse --abbrev-ref HEAD in the target repository checkout. When the agent has already switched to a feature branch (e.g. git checkout -b feature/FOO-123), this returns the feature branch instead of the repo's default branch.
This causes two distinct failures:
Symptom 1: extract-base-branch checks out wrong branch
The platform's extract-base-branch step uses base_branch from agent_output.json to checkout the workflow repository. When base_branch is set to the target repo's feature branch, the checkout fails because that branch does not exist in the workflow repo.
Symptom 2: Patch generation includes entire repo history (higher impact)
When branch == baseBranch (both are the feature branch), the patch generation strategies fail in sequence:
- Strategy 1: Tries
origin/feature/FOO-123 — does not exist (new branch). Falls through.
- Strategy 2: Checks
GITHUB_SHA — belongs to a different repo (multi-repo checkout). Falls through.
- Strategy 3 (fallback): Picks a random remote ref, computes merge-base against an ancient commit, and runs
git format-patch <ancient-commit>..feature/FOO-123 — producing a patch containing the entire repository history.
The resulting patch has hundreds of files (every file ever touched in the repo's history), which triggers E003: Cannot create pull request with more than N files. The agent's actual changes (e.g. 8 files, +41/-42 lines) are correct, but the inflated patch causes rejection.
The fallback (creating an issue instead) may also fail if issues are disabled on the target repo, resulting in complete silent failure with no PR and no issue.
Reproduction
- Configure a multi-repo workflow where repos are cloned under
repos/<name>/
- The agent creates a feature branch in a target repo:
git checkout -b feature/FOO-123
- Agent commits changes and calls
create_pull_request with branch: "feature/FOO-123" and no explicit base
- MCP server runs
git rev-parse --abbrev-ref HEAD → gets feature/FOO-123
- Both
branch and baseBranch are feature/FOO-123
- Symptom 1:
base_branch output is feature/FOO-123, causing workflow repo checkout failure
- Symptom 2: Patch generation falls through all strategies, lands on Strategy 3 with a bad merge-base, produces multi-MB patch with hundreds of historical commits
Server log evidence (Symptom 2 — patch generation)
[generate_git_patch] Strategy 1: Checking if branch 'feature/FOO-123' exists locally
[generate_git_patch] Strategy 1: Branch 'feature/FOO-123' exists locally
[generate_git_patch] Strategy 1 (full): Computing merge-base with feature/FOO-123
[generate_git_patch] Strategy 1 (full): origin/feature/FOO-123 not found locally, attempting fetch
[generate_git_patch] Strategy 1 (full): Fetch failed - fatal: couldn't find remote ref feature/FOO-123
[generate_git_patch] Strategy 1 (full): No remote refs available, falling through to Strategy 2
[generate_git_patch] Strategy 2: GITHUB_SHA not found in repo (cross-repo checkout?)
[generate_git_patch] Strategy 3: Cross-repo fallback - finding commits not reachable from remote refs
[generate_git_patch] Strategy 3: Found merge-base <ancient-commit> with ref refs/remotes/origin/<old-branch>
[generate_git_patch] Strategy 3: SUCCESS - Generated patch with 122231 lines
[generate_git_patch] Final: SUCCESS - patchSize=5730494 bytes, patchLines=122231
The patch contained 400 commits (the entire repo history), 210 unique files, and was 5.7 MB — for an actual change of 8 files.
Expected behavior
When base is not provided by the agent, the tool should resolve the repository's default branch (e.g. via git symbolic-ref refs/remotes/origin/HEAD) instead of using git rev-parse --abbrev-ref HEAD. This would:
- Set
baseBranch correctly for patch generation (merge-base would find the right common ancestor)
- Set
base_branch output correctly for the platform's checkout step
- Make both symptoms impossible
Current workaround
For Symptom 1 only: we patch the generated extract-base-branch step post-compile to validate the branch exists locally before using it. This does not fix Symptom 2.
For Symptom 2: no workaround exists. The agent's PR is silently lost. The only recovery is to re-run the workflow.
Environment
gh-aw CLI: v0.74.4
- Engine version: 1.0.48
Problem
The
safe-outputsMCP server determines the base branch by runninggit rev-parse --abbrev-ref HEADin the target repository checkout. When the agent has already switched to a feature branch (e.g.git checkout -b feature/FOO-123), this returns the feature branch instead of the repo's default branch.This causes two distinct failures:
Symptom 1:
extract-base-branchchecks out wrong branchThe platform's
extract-base-branchstep usesbase_branchfromagent_output.jsonto checkout the workflow repository. Whenbase_branchis set to the target repo's feature branch, the checkout fails because that branch does not exist in the workflow repo.Symptom 2: Patch generation includes entire repo history (higher impact)
When
branch == baseBranch(both are the feature branch), the patch generation strategies fail in sequence:origin/feature/FOO-123— does not exist (new branch). Falls through.GITHUB_SHA— belongs to a different repo (multi-repo checkout). Falls through.git format-patch <ancient-commit>..feature/FOO-123— producing a patch containing the entire repository history.The resulting patch has hundreds of files (every file ever touched in the repo's history), which triggers
E003: Cannot create pull request with more than N files. The agent's actual changes (e.g. 8 files, +41/-42 lines) are correct, but the inflated patch causes rejection.The fallback (creating an issue instead) may also fail if issues are disabled on the target repo, resulting in complete silent failure with no PR and no issue.
Reproduction
repos/<name>/git checkout -b feature/FOO-123create_pull_requestwithbranch: "feature/FOO-123"and no explicitbasegit rev-parse --abbrev-ref HEAD→ getsfeature/FOO-123branchandbaseBrancharefeature/FOO-123base_branchoutput isfeature/FOO-123, causing workflow repo checkout failureServer log evidence (Symptom 2 — patch generation)
The patch contained 400 commits (the entire repo history), 210 unique files, and was 5.7 MB — for an actual change of 8 files.
Expected behavior
When
baseis not provided by the agent, the tool should resolve the repository's default branch (e.g. viagit symbolic-ref refs/remotes/origin/HEAD) instead of usinggit rev-parse --abbrev-ref HEAD. This would:baseBranchcorrectly for patch generation (merge-base would find the right common ancestor)base_branchoutput correctly for the platform's checkout stepCurrent workaround
For Symptom 1 only: we patch the generated
extract-base-branchstep post-compile to validate the branch exists locally before using it. This does not fix Symptom 2.For Symptom 2: no workaround exists. The agent's PR is silently lost. The only recovery is to re-run the workflow.
Environment
gh-awCLI: v0.74.4