fix: accept agent-supplied branch in push_to_pull_request_branch (fixes #41643)#41654
Merged
Conversation
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
Contributor
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
Contributor
There was a problem hiding this comment.
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
branchto thepush_to_pull_request_branchtool input schema (both tool manifests) so agents can pass it underadditionalProperties: false. - Updates the tool description to instruct agents to pass
branchexplicitly in batch workflows. - Updates
pushToPullRequestBranchHandlerto honor an agent-suppliedbranchwhen present, falling back togetCurrentBranch()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
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test body