Skip to content

Add create-pull-request safe output to mention-in-pr workflows for fork PRs#487

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/offer-pr-for-remote-fork
Closed

Add create-pull-request safe output to mention-in-pr workflows for fork PRs#487
Copilot wants to merge 2 commits intomainfrom
copilot/offer-pr-for-remote-fork

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

When mentioned in a fork PR, the agent previously could only say "I can't push to fork branches" and suggest the author apply changes themselves. Now it can create a new PR in the base repo with the proposed changes instead.

Changes

  • Workflow source files (gh-aw-mention-in-pr.md, gh-aw-mention-in-pr-no-sandbox.md, gh-aw-mention-in-pr-by-id.md):

    • Import safe-output-create-pr.md fragment
    • Add draft-prs input (default: true)
    • Update constraints and fork PR instructions to use create_pull_request instead of giving up
    • Add create_pull_request to the Additional tools section
  • safe-output-push-to-pr.md fragment: Updated fork PR guidance to recommend create_pull_request as the alternative

  • README.md for all three workflows: Document new draft-prs input and create-pull-request safe output

  • Lock files: Recompiled via make compile (0 errors)

Agent behavior change

Before (fork PR, asked to fix code):

I cannot push to fork branches. Please apply the changes yourself.

After:

Creates a new PR in the base repo with the changes, references the original fork PR in the description, and comments on the original PR explaining what it did.

Original prompt

This section details on the original issue you should resolve

<issue_title>Offer PR if remote branch is on a fork</issue_title>
<issue_description>As we can't push to branches on forks, Let's offer a PR to a fork branch of we're mentioned in a PR that comes from a fork</issue_description>

<agent_instructions>Let's give this a shot</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…rk PRs

When a PR comes from a fork, the agent can now create a new PR in the
base repo with the proposed changes instead of just telling the user
it can't push to fork branches.

Changes:
- Add safe-output-create-pr.md fragment import to mention-in-pr,
  mention-in-pr-no-sandbox, and mention-in-pr-by-id workflows
- Add draft-prs input to all three workflows
- Update fork PR instructions to use create_pull_request
- Update safe-output-push-to-pr.md fragment fork guidance
- Update README.md files with new safe output and input
- Recompile all lock files

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
Copilot AI changed the title [WIP] Offer PR for branches on a fork Add create-pull-request safe output to mention-in-pr workflows for fork PRs Feb 28, 2026
@strawgate strawgate marked this pull request as ready for review February 28, 2026 21:03
@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

📝 Walkthrough

Walkthrough

This pull request extends GitHub Actions workflows to support creating new pull requests as an alternative to pushing changes directly, particularly for fork scenarios. The changes introduce a new create_pull_request tool across safe-outputs configurations, add a ready-to-make-pr safe-input tool for pre-PR validation checks, and introduce a draft-prs workflow input to control draft status. Fork PR handling is updated throughout to use create_pull_request to open a new PR in the base repository while referencing the original fork PR. Merge conflict resolution guidance is added to handle conflicts without merge commits. Multiple workflow lock files and markdown documentation are synchronized with these capability additions.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR fully implements issue #485: enables agent to create PRs in base repos when mentioned in fork PRs, replacing the previous 'cannot push' limitation.
Out of Scope Changes check ✅ Passed All changes are scoped to fork PR handling: workflow inputs (draft-prs), safe outputs (create_pull_request), and related documentation/guidance. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/offer-pr-for-remote-fork

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/gh-aw-fragments/safe-output-push-to-pr.md (1)

90-94: ⚠️ Potential issue | 🔴 Critical

Remove reference to non-existent baseRefName field.

The documented guidance references baseRefName from /tmp/pr-context/pr.json, but this field does not exist. The pr.json structure only contains headRefOid. Either add baseRefName to pr.json during generation or rewrite the merge conflict resolution guidance to use an alternative method to determine the base branch name.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/gh-aw-fragments/safe-output-push-to-pr.md around lines 90
- 94, The doc references a nonexistent pr.json field `baseRefName`; update the
guidance so it either (A) instructs the generator that creates
/tmp/pr-context/pr.json to include a `baseRefName` entry derived from the PR
metadata, or (B) replace `baseRefName` usage with a supported alternative (e.g.,
use `headRefOid` where appropriate or derive the base branch via the GitHub
action/ENV like GITHUB_BASE_REF or from the PR API) and update the steps that
mention resolving merge conflicts accordingly; ensure references to
`push_to_pull_request_branch` and `ready_to_push_to_pr` remain consistent with
the chosen approach.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/gh-aw-mention-in-pr-by-id.lock.yml:
- Around line 68-72: The new input "draft-prs" is defined but never passed into
the PR creation logic; update the source workflow/fragment that generates
create_pull_request so the handler consumes inputs.draft-prs (e.g., pass it into
the create_pull_request action or the function that constructs the PR payload)
and wire it through the safe-output/configuration handler path so the draft flag
is honored; do this change in the source workflow/fragment (not the compiled
.lock.yml), recompile the workflow to regenerate the .lock.yml, and ensure any
references to create_pull_request, safe-output handler, or the PR payload
builder include the draft boolean (inputs.draft-prs) propagation.

---

Outside diff comments:
In @.github/workflows/gh-aw-fragments/safe-output-push-to-pr.md:
- Around line 90-94: The doc references a nonexistent pr.json field
`baseRefName`; update the guidance so it either (A) instructs the generator that
creates /tmp/pr-context/pr.json to include a `baseRefName` entry derived from
the PR metadata, or (B) replace `baseRefName` usage with a supported alternative
(e.g., use `headRefOid` where appropriate or derive the base branch via the
GitHub action/ENV like GITHUB_BASE_REF or from the PR API) and update the steps
that mention resolving merge conflicts accordingly; ensure references to
`push_to_pull_request_branch` and `ready_to_push_to_pr` remain consistent with
the chosen approach.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 719b9fb and 26b14fa.

📒 Files selected for processing (12)
  • .github/workflows/gh-aw-fragments/safe-output-push-to-pr.md
  • .github/workflows/gh-aw-mention-in-pr-by-id.lock.yml
  • .github/workflows/gh-aw-mention-in-pr-by-id.md
  • .github/workflows/gh-aw-mention-in-pr-no-sandbox.lock.yml
  • .github/workflows/gh-aw-mention-in-pr-no-sandbox.md
  • .github/workflows/gh-aw-mention-in-pr.lock.yml
  • .github/workflows/gh-aw-mention-in-pr.md
  • .github/workflows/gh-aw-pr-actions-fixer.lock.yml
  • .github/workflows/gh-aw-pr-review-addresser.lock.yml
  • gh-agent-workflows/mention-in-pr-by-id/README.md
  • gh-agent-workflows/mention-in-pr-no-sandbox/README.md
  • gh-agent-workflows/mention-in-pr/README.md

Comment on lines +68 to +72
draft-prs:
default: true
description: Whether to create pull requests as drafts
required: false
type: boolean
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

draft-prs input is added but not wired into PR creation behavior

Line 68 introduces draft-prs, but the create_pull_request path still uses generic/default behavior and does not consume inputs.draft-prs in the safe-output configuration/handler path. This makes the new input effectively non-functional for callers.

Based on learnings, this .lock.yml should not be edited directly; wire draft-prs in the source workflow/fragment and recompile.

Also applies to: 782-783, 820-823, 2117-2117

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/gh-aw-mention-in-pr-by-id.lock.yml around lines 68 - 72,
The new input "draft-prs" is defined but never passed into the PR creation
logic; update the source workflow/fragment that generates create_pull_request so
the handler consumes inputs.draft-prs (e.g., pass it into the
create_pull_request action or the function that constructs the PR payload) and
wire it through the safe-output/configuration handler path so the draft flag is
honored; do this change in the source workflow/fragment (not the compiled
.lock.yml), recompile the workflow to regenerate the .lock.yml, and ensure any
references to create_pull_request, safe-output handler, or the PR payload
builder include the draft boolean (inputs.draft-prs) propagation.

@strawgate strawgate closed this Feb 28, 2026
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.

Offer PR if remote branch is on a fork

2 participants