Skip to content

fix: accept agent-supplied branch in push_to_pull_request_branch (fixes #41643)#41654

Merged
dsyme merged 2 commits into
mainfrom
fix/push-to-pr-branch-agent-supplied-branch
Jun 26, 2026
Merged

fix: accept agent-supplied branch in push_to_pull_request_branch (fixes #41643)#41654
dsyme merged 2 commits into
mainfrom
fix/push-to-pr-branch-agent-supplied-branch

Conversation

@dsyme

@dsyme dsyme commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

test body

Generated by PR Description Updater for #41654 · 59.2 AIC · ⌖ 12 AIC · ⊞ 4.6K ·

Fixes #41643.

In batch workflows that loop over multiple PRs, the working tree may be
checked out to a different PR's branch by the time the MCP handler runs.
The previous implementation unconditionally stripped the agent-supplied
'branch' argument and inferred the source branch from git HEAD, causing
the bundle to be generated for the wrong branch. The apply step then
failed with:

  fatal: couldn't find remote ref refs/heads/<pr-head-branch>

Fix:
- Remove the defensive strip of the agent-supplied 'branch' argument
- Use the agent-supplied branch directly when provided
- Fall back to getCurrentBranch() only when branch is omitted (backward
  compat for single-PR workflows where HEAD is reliable)
- Add 'branch' property to the push_to_pull_request_branch input schema
  in both safe_outputs_tools.json files (was blocked by
  additionalProperties: false, so agents couldn't pass it at all)
- Update tool description to instruct agents to supply 'branch'
  explicitly in batch workflows
Copilot AI review requested due to automatic review settings June 26, 2026 10:50
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

CI lights the path
Green checks bloom at dawn
Quiet bots still sing

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Generated by 🧪 Smoke CI for #41654 ·

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes push_to_pull_request_branch in multi-PR batch workflows by allowing the agent to explicitly provide the local source branch to bundle from, avoiding accidental bundling from the currently checked-out (wrong) branch.

Changes:

  • Adds branch to the push_to_pull_request_branch tool input schema (both tool manifests) so agents can pass it under additionalProperties: false.
  • Updates the tool description to instruct agents to pass branch explicitly in batch workflows.
  • Updates pushToPullRequestBranchHandler to honor an agent-supplied branch when present, falling back to getCurrentBranch() only when omitted.
Show a summary per file
File Description
pkg/workflow/js/safe_outputs_tools.json Declares branch in the tool schema and updates guidance so agents can pass it in batch workflows.
actions/setup/js/safe_outputs_tools.json Mirrors the schema + description update for the runtime tool manifest used by the setup/actions side.
actions/setup/js/safe_outputs_handlers.cjs Removes the branch “defensive strip” and uses agent-supplied branch with a fallback to current HEAD for backward compatibility.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Low

@dsyme dsyme merged commit fb30670 into main Jun 26, 2026
33 checks passed
@dsyme dsyme deleted the fix/push-to-pr-branch-agent-supplied-branch branch June 26, 2026 11:09
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.

2 participants