Skip to content

fix: create_pull_request branch guidance, PR-comment tool selection, and shallow clone fallback#24123

Merged
pelikhan merged 4 commits intomainfrom
copilot/improve-create-pull-request-guidance
Apr 2, 2026
Merged

fix: create_pull_request branch guidance, PR-comment tool selection, and shallow clone fallback#24123
pelikhan merged 4 commits intomainfrom
copilot/improve-create-pull-request-guidance

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

Three related issues caused create_pull_request failures when agents were invoked via PR comments: the agent invented a non-existent branch name, used create_pull_request when push_to_pull_request_branch was the correct tool, and the fallback path broke on shallow clones.

Issue 1 — Branch name guidance (safe_outputs_create_pull_request.md)

Added an explicit Important block: the branch parameter must equal the output of git branch --show-current. Never invent a branch name.

Issue 2 — Prefer push_to_pull_request_branch in PR comment context

New file pr_context_push_to_pr_branch_guidance.md tells the agent to prefer push_to_pull_request_branch over create_pull_request when triggered by a PR comment. Injected in unified_prompt_step.go only when:

  • runtime event is a PR comment (existing shell condition), and
  • push-to-pull-request-branch is actually configured in the workflow (compile-time gate)

Issue 3 — Shallow clone fallback (create_pull_request.cjs)

Before git cat-file -e <base_commit>, attempt to fetch the commit explicitly so it's available in fetch-depth: 1 checkouts:

try {
  await exec.exec("git", ["fetch", "origin", originalBaseCommit, "--depth=1"]);
} catch (fetchError) {
  core.info(`Note: could not fetch base commit ${originalBaseCommit} explicitly (...); will verify local availability next`);
}
await exec.exec("git", ["cat-file", "-e", originalBaseCommit]);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw -pack /home/REDACTED/work/gh-aw/gh-aw/cmd/gh-aw/main.go (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw n_pins.go n_pins_integrati-v n_pins_logging_test.go n_pi�� tions-lock.json pkg/workflow/data/action_pins.json; \ echo &#34;��� Action pins synced successfullyinfocmp n_reference_test.go n_resolver.go n_resolver_test./usr/bin/gh n_sha_checker.goapi n_sha_checker_ingraphql n_sha_checker_te-f (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name 64/pkg/tool/linu-p node 64/bin/go -d **/*.cjs 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD ha8_stub.s go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name --write ../../../**/*.jsGOMOD 64/bin/go --ignore-path ../../../.pretti-c ache/go/1.25.0/x&#34;prettier&#34; --check &#39;**/*.cjs&#39; &#39;**/*.ts&#39; &#39;**/*.json&#39; --ignore-path ../../../.prettierignore go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel go /usr/bin/git lGitbranch_with_git lGitbranch_with_rev-parse 64/bin/go git add test.txt go /usr/bin/git on&#39; --ignore-patgit GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git rev-�� --show-toplevel git /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/link --show-toplevel ache/go/1.25.0/xrev-parse /usr/bin/git /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha npx prettier --write &#39;../../../**/*.json&#39; &#39;!../../../pkg/workflow/js/**/*.json&#39; --ignore-path git /usr/bin/tail --show-toplevel git ache/node/24.14.--show-toplevel tail -15 /usr/bin/git git /home/REDACTED/work/_temp/uv-python-dir/node ignore-path ../.git git ache/node/24.14.--show-toplevel node (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha k/gh-aw/gh-aw/.github/workflows scripts/**/*.js /bin/sh .prettierignore 64/pkg/tool/linurev-parse 64/bin/go /bin/sh -c git-upload-pack &#39;/tmp/TestParseDefaultBranchFromLsRemoteWithRealGitmain_branch565419988/001&#39; l /usr/bin/git npx prettier --wgit 64/pkg/tool/linurev-parse 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel git 64/pkg/tool/linux_amd64/cgo --git-dir x_amd64/cgo /usr/bin/git 64/pkg/tool/linux_amd64/cgo rev-�� --show-toplevel git /usr/bin/git --show-toplevel go e/git-remote-htt--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel git ules/.bin/node 01 git /usr/bin/git git tion�� . git bin/node -b feature-branch /usr/bin/git erignore (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha ay_c1891600490/001 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel go /usr/bin/git i-lint &gt;/dev/nulgit GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE bin/node git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel go /usr/bin/git blog-auditor.md GO111MODULE /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel go 1/x64/bin/node -json GO111MODULE 1/x64/bin/node git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha ts.result Test User /usr/bin/git -json GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -v go /usr/bin/git -json GO111MODULE tnet/tools/sh git rev-�� --show-toplevel go /usr/bin/git ck &#39;**/*.cjs&#39; &#39;*git GO111MODULE /opt/hostedtoolc--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build941950207/b213/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/modelcontextprotocol/go-sdk@v1.4.1/internal/json/json.go -o /tmp/go-build361-p o 64/bin/go -p github.com/githu-o -lang=go1.25 go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build2893203388/b431/importcfg -pack /tmp/go-build2893203388/b431/_testmain.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel go mple.com/org/repo.git -json GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha npx prettier --write &#39;**/*.cjs&#39; &#39;**/*.ts&#39; &#39;**/*.json&#39; --ignore-path ../../../.pr**/*.json infocmp /opt/hostedtoolcache/uv/0.11.3/x86_64/sh xterm-color git /usr/bin/git sh -c &#34;prettier&#34; --write &#39;scripts/**/*.js&#39; --ignore-path .prettierignore --log-level=e!../../../pkg/wogit git /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/node t992515104/.githgit git ache/node/24.14.--show-toplevel node (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel gh /usr/bin/git download 12345 /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha run format:cjs /opt/hostedtoolcache/node/24.14.1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/n--show-toplevel --show-toplevel git /usr/bin/git sh -c &#34;prettier&#34; --write &#39;scripts/**/*.js&#39; --ignore-path .prettierignore --log-level=e!../../../pkg/wogit git /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/prettier --show-toplevel git ache/node/24.14.--show-toplevel prettier (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha h ../../../.prettierignore (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .visibility on&#39; --ignore-path ../../../.pret--log-level=error (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0 --jq .object.sha (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha xterm-color go /usr/bin/git re GO111MODULE 64/bin/go git rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha --show-toplevel git mpt\|TestUnifiedPrompt\|TestSafeOutputs --show-toplevel go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha ./... git /opt/hostedtoolcache/uv/0.11.3/x86_64/node --show-toplevel git .test node /opt�� prettier --write /home/REDACTED/work/_temp/ghcca-node/node/bin/sh --ignore-path .prettierignore --log-level=erro--show-toplevel sh (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha 5858399/b451/workflow.test GO111MODULE 5858399/b451/importcfg.link GOINSECURE GOMOD GOMODCACHE Fl9XNiXAQowgn/9gXo0RWN9vrX4f7c2FAh/1_wmpnzaCcBPPc1usrRV/PJAPt-ZFl9XNiXAQowgn /hom�� ry=1 l (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel ache/node/24.14.1/x64/bin/node /usr/bin/mkdir --show-toplevel go /usr/bin/git mkdir -p /tmp/gh-aw git /usr/bin/git add origin DiscussionsEnabl--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha 985ce8c11130c57bec104d79:.github/workflows/craft.lock.yml git 64/bin/sh --show-toplevel git /usr/bin/git git init�� *.json&#39; &#39;!../../../pkg/workflow/js/**/*.json&#39; --ignore-path ../../../.prettierignore git h ub/workflows git /usr/bin/git /usr/bin/git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha t0 GO111MODULE (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git log --oneline -10 /usr/bin/git --show-toplevel go /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha 985ce8c11130c57bec104d79:.github/workflows/craft.lock.yml git git --show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE f9cd34ab GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 efaultBranchFromLsRemoteWithRealGitcustom_branch266572572/001&#39; k/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env ck &#39;**/*.cjs&#39; &#39;**/*.ts&#39; &#39;**/*.js--detach GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 git /usr/bin/git --show-toplevel git /home/REDACTED/.do/tmp/gh-aw-test-runs/20260402-140627-54625/test-2591801696 git estl�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a @v1.1.3/cpu/x86/x86.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet ache�� audit-workflows.md GO111MODULE bin/golangci-lint GOINSECURE GOMOD GOMODCACHE erignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 git x_amd64/asm --show-toplevel git /opt/hostedtoolc--show-toplevel x_amd64/asm rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 at.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a rotocol/go-sdk@v1.4.1/internal/xmain 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE es/.bin/node GOINSECURE GOMOD GOMODCACHE go ache�� Onlymin-integrity_with_repos_array_c1891600490/001 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE erignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 git x_amd64/cgo --show-toplevel git /home/REDACTED/wor/tmp/gh-aw-test-runs/20260402-140627-54625/test-2591801696 x_amd64/cgo rev-�� --show-toplevel bash 1/x64/bin/node --noprofile 1/x64/bin/npm /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE 64/pkg/tool/linux_amd64/compile sm); \ wasm-optgit GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env 1027740570/.github/workflows 0/internal/tag/tag.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 efaultBranchFromLsRemoteWithRealGitbranch_with_hyphen1453820553/001&#39; k/gh-aw/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env auto-triage-issues.md GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 git /usr/bin/git --show-toplevel git /usr/local/sbin//tmp/gh-aw-test-runs/20260402-140627-54625/test-2591801696 git rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env 2950780444/.github/workflows GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE At,event,headBranch,headSha,displayTitle GOINSECURE GOMOD GOMODCACHE go env CompiledOutput3869073924/001 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 git /usr/bin/git --show-toplevel git /usr/local/bin/bHEAD git rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 f9cd34ab:go.mod 64/pkg/tool/linu-nolocalimports GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu/tmp/go-build2893203388/b440/_testmain.go env 1027740570/.github/workflows 0/internal/language/common.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE k/gh-aw/gh-aw/actions/setup/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env CompiledOutput3869073924/001 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 git /usr/bin/git --show-toplevel git /usr/sbin/bash git rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ks/uHvMf0NAnOjab896TNzs/AXMwmaH9config env _.a 0/internal/stringset/set.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 sRemoteWithRealGitbranch_with_hyphen1453820553/002/work k/gh-aw/gh-aw/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env ck &#39;**/*.cjs&#39; &#39;**/*.ts&#39; &#39;**/*.json&#39; --ignore-path ../../../.prettierignore GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 git /usr/bin/git --show-toplevel git /usr/bin/bash git rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path 64/pkg/tool/linu-p node 64/bin/go -d **/*.cjs 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE 64/pkg/tool/linu.github/workflows/test.md env md GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE eutil GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel go /usr/bin/git hub/workflows GO111MODULE 1/x64/bin/npm git rev-�� --show-toplevel go /usr/bin/git 2808310826/.githgit GO111MODULE ules/.bin/sh git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel sh /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel sh /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel git /usr/bin/git ath ../../../.prgit git /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel node /usr/bin/git re --log-level=egit 1/x64/bin/npm /opt/hostedtoolc--verify git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go 4199�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel sh /usr/bin/git runs/20260402-14git GOPROXY ache/node/24.14.--show-toplevel git rev-�� --show-toplevel sh /usr/bin/git sistency_Inlinedbash sh /usr/lib/git-cor--noprofile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha ath ../../../.pr**/*.json TOKEN&#34;; }; f get--ignore-path /opt/hostedtoolc../../../.prettierignore --show-toplevel ue &amp;&amp; echo &#34;chai-c /usr/bin/git node er /workflows/poem-bot.lock.yml git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE 5Xtw49I/oDhJCmGErev-parse (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� &#39;origin&#39; &#39;origin&#39; /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env cli/install.sh..-errorsas GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha GOPATH GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go go env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git nfig/composer/ve--objects git rev-�� --show-toplevel (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/# --jq .object.sha w/js/**/*.json&#39; --ignore-path (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel sh /usr/bin/git ithub/workflows/git GOPROXY ache/node/24.14.--show-toplevel git rev-�� --show-toplevel sh /usr/bin/git sistency_Inlinedbash sh /usr/lib/git-cor--noprofile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha ath ../../../.pr**/*.json git /opt/hostedtoolc../../../.prettierignore --show-toplevel git 64/bin/node node er /workflows/poem-bot.lock.yml git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel git /usr/bin/git node (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com env 1457720273/.github/workflows CPEgZN3Om 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env ck &#39;scripts/**/*.js&#39; --ignore-path .prettierignore GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion --show-toplevel git /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel bash 1/x64/bin/node --noprofile git /usr/bin/git git (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go -p github.com/githu-o -lang=go1.25 go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo -nolocalimports -importcfg /tmp/go-build2893203388/b414/importcfg -pack /tmp/go-build2893203388/b414/_testmain.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE y.s (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go --ignore-path ../../../.pretti/home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/pre�� x_amd64/vet go env ath ../../../.pr**/*.json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2893203388/b396/cli.test /tmp/go-build2893203388/b396/cli.test -test.testlogfile=/tmp/go-build2893203388/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true -nolocalimports -importcfg /tmp/go-build941950207/b210/importcfg -pack -V=f�� 64/pkg/tool/linu-p node 64/bin/go -d **/*.cjs 64/bin/go go (http block)
    • Triggering command: /tmp/go-build1355858399/b396/cli.test /tmp/go-build1355858399/b396/cli.test -test.testlogfile=/tmp/go-build1355858399/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true .prettierignore --log-level=erroenv 64/pkg/tool/linu-json node /hom�� --write ../../../**/*.jsGOMOD 64/bin/go &#34;; \ else \ echo &#34;��� Warning: .github/aw/actions-lock.json does not exist yet&#34;; \ fi ../../../.pretti/home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/prettier ache/go/1.25.0/x--check go (http block)
    • Triggering command: /tmp/go-build3755806604/b001/cli.test /tmp/go-build3755806604/b001/cli.test -test.testlogfile=/tmp/go-build3755806604/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=. --show-toplevel git ache/go/1.25.0/x64/bin/node --show-toplevel git 64/pkg/tool/linux_amd64/asm in 2&gt;/dev/null | tr &#39;\n&#39; &#39;:&#39;)$PATH&#34;; [ -n &#34;$GOROOT&#34; ] &amp;&amp; export ache�� --show-toplevel nly /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build2893203388/b396/importcfg -pack /tmp/go-build2893203388/b396/_testmain.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name ../../../**/*.jsGOINSECURE !../../../pkg/woGOMOD 64/bin/go ./cmd/... ./pkg/...; \ else \ echo &#34;golangci-lint is not installed. Run &#39;make deps-dev&#39; to in j3JKKMOCL ache/go/1.25.0/x&#34;prettier&#34; --check &#39;**/*.cjs&#39; &#39;**/*.ts&#39; &#39;**/*.json&#39; --ignore-path ../../../.prettierignore go env q &#34;All matched files use Prettier code style&#34;; then \ echo &#34;JSON files are not formatted. Run &#39;/usr/lib/git-core/git GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --show-toplevel 64/pkg/tool/linux_amd64/cgo /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel e/git-remote-httjs/fuzz_sanitize_output_harness.cjs /usr/bin/git git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…shallow clone fallback

- Issue 1: Strengthen branch name guidance in safe_outputs_create_pull_request.md
  to make clear the branch parameter must match git branch --show-current exactly

- Issue 2: Add pr_context_push_to_pr_branch_guidance.md with guidance to prefer
  push_to_pull_request_branch over create_pull_request when triggered by a PR comment.
  Inject it conditionally when push-to-pull-request-branch is configured.

- Issue 3: Fetch base commit before git cat-file -e in create_pull_request.cjs
  fallback path to handle shallow clone (fetch-depth: 1) environments.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/507fdac8-ffba-44f8-9607-afd77e808000

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve guidance for branch name in create pull request fix: create_pull_request branch guidance, PR-comment tool selection, and shallow clone fallback Apr 2, 2026
Copilot finished work on behalf of dsyme April 2, 2026 14:13
Copilot AI requested a review from dsyme April 2, 2026 14:13
@pelikhan pelikhan marked this pull request as ready for review April 2, 2026 16:58
Copilot AI review requested due to automatic review settings April 2, 2026 16:58
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 2, 2026

@copilot Merge main and recompile

…e-pull-request-guidance

# Conflicts:
#	.github/workflows/tidy.lock.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves reliability of PR creation/push flows when workflows are triggered via PR comments by tightening prompt/tool guidance and hardening create_pull_request for shallow checkouts.

Changes:

  • Adds explicit guidance to never invent the branch value for create_pull_request (must match git branch --show-current).
  • Adds PR-comment-specific guidance to prefer push_to_pull_request_branch (when configured) over opening a new PR.
  • Updates create_pull_request fallback logic to attempt fetching the recorded base commit in shallow clones before verifying its existence.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/workflow/unified_prompt_step.go Conditionally injects PR-comment tool-preference guidance when push_to_pull_request_branch is configured.
pkg/workflow/prompt_constants.go Adds constant for the new PR-comment guidance prompt filename.
actions/setup/md/safe_outputs_create_pull_request.md Clarifies correct branch selection and verification for create_pull_request.
actions/setup/md/pr_context_push_to_pr_branch_guidance.md New prompt fragment steering PR-comment runs toward push_to_pull_request_branch.
actions/setup/js/create_pull_request.cjs Shallow-clone fallback: attempts git fetch of the recorded base commit before git cat-file -e.
.github/workflows/tidy.lock.yml Includes the new PR-comment guidance prompt in the unified prompt assembly.
.github/workflows/poem-bot.lock.yml Includes the new PR-comment guidance prompt in the unified prompt assembly.
.github/workflows/mergefest.lock.yml Includes the new PR-comment guidance prompt in the unified prompt assembly.
.github/workflows/craft.lock.yml Includes the new PR-comment guidance prompt in the unified prompt assembly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +276 to +286
// When push_to_pull_request_branch is configured, add guidance to prefer it over
// create_pull_request when the workflow was triggered by a PR comment.
if data.SafeOutputs != nil && data.SafeOutputs.PushToPullRequestBranch != nil {
unifiedPromptLog.Print("Adding push-to-PR-branch tool preference guidance for PR comment context")
sections = append(sections, PromptSection{
Content: prContextPushToPRBranchGuidanceFile,
IsFile: true,
ShellCondition: shellCondition,
EnvVars: envVars,
})
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this guidance is injected when (1) the runtime event is a PR comment and (2) push_to_pull_request_branch is configured. In code it is additionally gated by needsCheckout and hasContentsRead because it lives inside the existing PR-context block, so PR-comment runs that don't require checkout (or lack contents:read) will not receive the tool-preference guidance. Either update the PR description to match this behavior, or move this injection outside the needsCheckout/hasContentsRead gate so it aligns with the stated conditions.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,4 @@

<pr-comment-tool-guidance>
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than `create_pull_request` which opens a separate new pull request. Only use `create_pull_request` if the instructions explicitly ask you to create a new, separate pull request.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guidance references create_pull_request as an alternative, but some workflows enable push_to_pull_request_branch without enabling create_pull_request (e.g. .github/workflows/mergefest.lock.yml safe-output tools list). Mentioning an unavailable tool here can confuse the agent and increase the chance it tries to call a tool that isn't configured. Consider rewording to avoid naming create_pull_request unless it’s actually present (or phrase it generically as “opening a new PR”) and/or conditionally include this file only when both tools are enabled.

Suggested change
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than `create_pull_request` which opens a separate new pull request. Only use `create_pull_request` if the instructions explicitly ask you to create a new, separate pull request.
When triggered by a pull request comment, if you need to push code changes, prefer using `push_to_pull_request_branch` to add commits to the existing pull request branch rather than opening a separate new pull request. Only create a new, separate pull request if the instructions explicitly ask you to do so.

Copilot uses AI. Check for mistakes.
Comment on lines +898 to +906
// In shallow clones (fetch-depth: 1) the base commit may not be locally available.
// Attempt to fetch it explicitly before checking whether it exists.
try {
await exec.exec("git", ["fetch", "origin", originalBaseCommit, "--depth=1"]);
} catch (fetchError) {
// Non-fatal: the commit may already be available, or the server may not support
// fetching individual SHAs (e.g. some GHE configurations). Log for troubleshooting.
core.info(`Note: could not fetch base commit ${originalBaseCommit} explicitly (${fetchError instanceof Error ? fetchError.message : String(fetchError)}); will verify local availability next`);
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (explicitly git fetching originalBaseCommit in shallow clones) isn't covered by the existing tests in create_pull_request.test.cjs. Consider adding a unit test that asserts the fetch is attempted before git cat-file -e, and that fetch failures are treated as non-fatal (still proceeding to the local availability check).

Copilot uses AI. Check for mistakes.
Comment on lines 240 to +241
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats the exact same shell condition twice in a row. Consider combining into a single if block that cats both prompt fragments to avoid duplication and reduce the risk of the two conditions drifting over time.

Suggested change
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then

Copilot uses AI. Check for mistakes.
Comment on lines 247 to +248
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats the exact same shell condition twice in a row. Consider combining into a single if block that cats both prompt fragments to avoid duplication and reduce the risk of the two conditions drifting over time.

Suggested change
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then

Copilot uses AI. Check for mistakes.
Comment on lines 221 to +222
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats the exact same shell condition twice in a row. Consider combining into a single if block that cats both prompt fragments to avoid duplication and reduce the risk of the two conditions drifting over time.

Suggested change
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then

Copilot uses AI. Check for mistakes.
Comment on lines 218 to +219
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats the exact same shell condition twice in a row. Consider combining into a single if block that cats both prompt fragments to avoid duplication and reduce the risk of the two conditions drifting over time.

Suggested change
fi
if [ "$GITHUB_EVENT_NAME" = "issue_comment" ] && [ -n "$GH_AW_IS_PR_COMMENT" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review_comment" ] || [ "$GITHUB_EVENT_NAME" = "pull_request_review" ]; then

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 2, 2026

@copilot Merge main and recompile

Done — merged main and recompiled all 179 workflow files successfully (d50341c). One conflict in tidy.lock.yml was resolved by keeping both the new pr_context_push_to_pr_branch_guidance.md section from this branch and the updated heredoc delimiter from main.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw -embedcfg /tmp/go-build443128459/b063/embedcfg -pack (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .visibility (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0 --jq .object.sha (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/# --jq .object.sha (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from pelikhan April 2, 2026 17:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Hey @Copilot 👋 — great work tracking down and fixing these three create_pull_request failure modes for PR-comment-triggered agents! The shallow-clone fetch fallback and the push_to_pull_request_branch preference guidance are both solid additions.

One thing that would make this PR stronger before merge:

  • Add tests — both companion test files exist but weren't updated:
    • actions/setup/js/create_pull_request.test.cjs — add a case for the shallow-clone path: mock a git fetch origin <sha> --depth=1 that fails (simulating a GHE that rejects SHA fetches) and verify the code gracefully falls through to git cat-file -e without throwing.
    • pkg/workflow/unified_prompt_step_test.go — add a test asserting that when SafeOutputs.PushToPullRequestBranch is non-nil the compiled sections include a PromptSection with Content: "pr_context_push_to_pr_branch_guidance.md", and that when it's nil no such section is added.

If you'd like a hand, you can assign this prompt to your coding agent:

Add missing test coverage for PR #24123 changes in github/gh-aw.

1. In `actions/setup/js/create_pull_request.test.cjs`:
   - Add a test for the shallow-clone fallback path added around line 895.
   - Scenario A: `git fetch origin <sha> --depth=1` succeeds → `git cat-file -e` is called with the commit SHA.
   - Scenario B: `git fetch origin <sha> --depth=1` throws → error is caught, `core.info` is called with the Note message, and `git cat-file -e` is still called (non-fatal).
   - Follow the existing mock patterns in the file (mock `exec.exec`, spy on `core.info`).

2. In `pkg/workflow/unified_prompt_step_test.go`:
   - Add a test for `collectPromptSections` that verifies the `prContextPushToPRBranchGuidanceFile` section is appended when `data.SafeOutputs.PushToPullRequestBranch != nil` and the PR-comment shell condition is active.
   - Add a corresponding negative test: when `data.SafeOutputs.PushToPullRequestBranch == nil`, the section must NOT be present.
   - Follow the existing table-driven test style in the file.

Run `make agent-finish` when done to confirm all checks pass.

Generated by Contribution Check ·

@pelikhan pelikhan merged commit 6d7fc80 into main Apr 2, 2026
51 checks passed
@pelikhan pelikhan deleted the copilot/improve-create-pull-request-guidance branch April 2, 2026 17:18
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.

create_pull_request: branch name guidance, PR-comment context tool selection, and shallow clone fallback failures

4 participants