Align title-prefix tool description constraints across all safe output handlers#18834
Merged
Align title-prefix tool description constraints across all safe output handlers#18834
Conversation
…ranch instead of rejecting When title-prefix was configured in push-to-pull-request-branch, the handler would reject the push if the existing PR's title didn't start with the required prefix. Instead, auto-add the prefix via GitHub API (consistent with how create_pull_request handles it). Also add title-prefix to the tool description for push_to_pull_request_branch so agents are informed about the prefix requirement. Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix missing safe output handler invocation
Auto-apply title prefix in push_to_pull_request_branch instead of rejecting
Feb 28, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes push_to_pull_request_branch behavior when a title-prefix constraint is configured by automatically applying the prefix to the existing PR title (via pulls.update) instead of rejecting the push, aligning behavior with create_pull_request. It also exposes the title-prefix constraint in the generated tool description so agents are aware of the enforced prefix.
Changes:
- Update
push_to_pull_request_branchto auto-prefix PR titles using the sharedsanitizeTitle+applyTitlePrefixpipeline andgithub.rest.pulls.update. - Enhance tool description generation to include
TitlePrefixconstraints forpush_to_pull_request_branch. - Adjust/add tests in JS and Go to validate the new behavior and constraint description.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/push_to_pull_request_branch.cjs | Auto-applies configured title prefix by updating the PR title instead of failing the handler. |
| actions/setup/js/push_to_pull_request_branch.test.cjs | Updates tests to expect a PR title update call rather than rejection when prefix is missing. |
| pkg/workflow/tool_description_enhancer.go | Adds TitlePrefix constraint text for push_to_pull_request_branch tool descriptions. |
| pkg/workflow/safe_outputs_tools_test.go | Adds coverage ensuring the new tool description constraint text is emitted. |
Comments suppressed due to low confidence (1)
actions/setup/js/push_to_pull_request_branch.cjs:304
- The log message
✓ Title prefix appliedis emitted whenevertitlePrefixis configured, even if the PR title already had the prefix and nopulls.updatecall was made. This can be misleading in run logs. Consider logging a message that reflects both cases (e.g., "already present" vs "updated") or only logging "applied" inside the branch where the title is actually updated.
if (titlePrefix) {
core.info(`✓ Title prefix applied: "${titlePrefix}"`);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dsyme
reviewed
Feb 28, 2026
…idation push-to-pull-request-branch is an additive operation (pushing to an existing PR), so it should validate the required title prefix (rejecting if missing) rather than auto-applying it. Auto-apply is correct for creation types (create_pull_request, create_issue, create_discussion) where the prefix is added when creating new content. The tool description constraint wording is updated to accurately describe the validation behavior: "must start with" instead of "will be prefixed with". Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot
AI
changed the title
Auto-apply title prefix in push_to_pull_request_branch instead of rejecting
Add title-prefix constraint to push_to_pull_request_branch tool description
Feb 28, 2026
…t handlers Add missing title-prefix constraints to tool descriptions for: - update_issue: "The target issue title must start with X" - close_issue: "Only issues with title prefix X can be closed" - close_discussion: "Only discussions with title prefix X can be closed" - link_sub_issue: parent and sub title prefix constraints These were missing from agent tool descriptions while close_pull_request already had its RequiredTitlePrefix constraint. All handler behaviors are correct - only the tool description visibility was missing. Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Copilot
AI
changed the title
Add title-prefix constraint to push_to_pull_request_branch tool description
Align title-prefix tool description constraints across all safe output handlers
Feb 28, 2026
dsyme
approved these changes
Feb 28, 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.
Safe output handlers with
title-prefixconfiguration follow two distinct behaviors depending on their type:create_pull_request,create_issue,create_discussion): auto-apply the prefix when creating new contentpush_to_pull_request_branch,update_issue): validate that the existing title starts with the required prefix, rejecting if notclose_pull_request,close_issue,close_discussion): only operate on entities whose title already matchesrequired_title_prefixPreviously, the
title-prefixconstraint was missing from several tool descriptions, leaving agents unaware of prefix requirements at tool call time.Changes
tool_description_enhancer.go: Added missing title-prefix constraints for all affected handlers:push_to_pull_request_branch:"The target pull request title must start with X"(validation semantics)update_issue:"The target issue title must start with X"(validation semantics)close_issue:"Only issues with title prefix X can be closed"(consistent with existingclose_pull_request)close_discussion:"Only discussions with title prefix X can be closed"link_sub_issue: parent and sub title prefix constraintsTests: Added Go test cases for each new constraint in
TestEnhanceToolDescription.No handler behaviors were changed — all creation, additive, and filter types were already correct. Only the tool description visibility was missing.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.