Skip to content

Align title-prefix tool description constraints across all safe output handlers#18834

Merged
pelikhan merged 6 commits intomainfrom
copilot/fix-safe-output-handler
Feb 28, 2026
Merged

Align title-prefix tool description constraints across all safe output handlers#18834
pelikhan merged 6 commits intomainfrom
copilot/fix-safe-output-handler

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Safe output handlers with title-prefix configuration follow two distinct behaviors depending on their type:

  • Creation types (create_pull_request, create_issue, create_discussion): auto-apply the prefix when creating new content
  • Additive/modification types (push_to_pull_request_branch, update_issue): validate that the existing title starts with the required prefix, rejecting if not
  • Filter types (close_pull_request, close_issue, close_discussion): only operate on entities whose title already matches required_title_prefix

Previously, the title-prefix constraint 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 existing close_pull_request)
    • close_discussion: "Only discussions with title prefix X can be closed"
    • link_sub_issue: parent and sub title prefix constraints
  • Tests: 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

This section details on the original issue you should resolve

<issue_title>Safe output was created but no pull request safe output handler happened</issue_title>
<issue_description>This run is strange, there is a safe output but no safe output handler was invoked for the PR

https://github.com/fsprojects/FSharp.Data/actions/runs/22520621714
</issue_description>

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

@dsyme Safe output data looks ok
{
    "body": "🤖 *This PR was created by Repo Assist, an automated AI assistant, working on github/gh-aw#1678.*\n\nPart of the documentation effort requested in github/gh-aw#1678 — adds XML doc comments to four source files covering the core conversion APIs.\n\n## What changed\n\nAdded `<summary>`, `<param>`, and `<returns>` XML doc comments to all previously undocumented public methods in:\n\n- **`JsonConversions.fs`** — all 11 static conversion methods (`AsString`, `AsInteger`, `AsInteger64`, `AsDecimal`, `AsFloat`, `AsBoolean`, `AsDateTime`, `AsDateTimeOffset`, `AsTimeSpan`, `AsDateOnly`, `AsTimeOnly`, `AsGuid`)\n- **`TextConversions.fs`** — all public static conversion methods (`AsInteger`, `AsInteger64`, `AsDecimal`, `AsFloat`, `AsBoolean`, `AsDateTime`, `AsDateTimeOffset`, `AsTimeSpan`, `AsDateOnly`, `AsTimeOnly`, `AsGuid`)\n- **`CsvExtensions.fs`** — all `StringExtensions` public extension methods (9 methods)\n- **`CsvFile.fs`** — `Parse`, `Load` (stream overload), `Load` (TextReader overload), `Load` (URI overload), and `AsyncLoad` static methods\n\nExisting `///` style comments were retained or replaced with proper XML doc format where arguments were involved. Internal/private members were not touched.\n\n## Test Status\n\n- ✅ `src/FSharp.Data.Runtime.Utilities` — builds successfully\n- ✅ `src/FSharp.Data.Json.Core` — builds successfully (0 errors)\n- ✅ `src/FSharp.Data.Csv.Core` — builds successfully (0 errors)\n- ✅ Fantomas formatting check — all 4 files unchanged (already correctly formatted)",
    "branch": "repo-assist/docs-issue-1678-json-csv-text-conversions",
    "labels": "documentation",
    "title": "Add XML doc comments to JsonConversions, TextConversions, CsvExtensions, CsvFile",
    "type": "create_pull_request",
    "patch_path": "/tmp/gh-aw/aw-repo-assist-docs-issue-1678-json-csv-text-conversions.patch"
}
```</body></comment_new>
<comment_new><author>@dsyme</author><body>
Oh it was rejected because of the title-prefix perhaps.  Is the title prefix a rejection condition or is it automatically added?  

If it's a rejection condition we should not reject an entire PR, we should just add the prefix.

EIther way we should strengthen our generated prompting for all safe outputs that have a title-prefix configuration option. </body></comment_new>
</comments>


🔒 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.

…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
@dsyme dsyme marked this pull request as ready for review February 28, 2026 13:46
Copilot AI review requested due to automatic review settings February 28, 2026 13:46
Copy link
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

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_branch to auto-prefix PR titles using the shared sanitizeTitle + applyTitlePrefix pipeline and github.rest.pulls.update.
  • Enhance tool description generation to include TitlePrefix constraints for push_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 applied is emitted whenever titlePrefix is configured, even if the PR title already had the prefix and no pulls.update call 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.

…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
@pelikhan pelikhan merged commit 9d131c5 into main Feb 28, 2026
48 checks passed
@pelikhan pelikhan deleted the copilot/fix-safe-output-handler branch February 28, 2026 17:55
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.

Safe output was created but no pull request safe output handler happened

4 participants