Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the feature-flagged update_issue_labels MCP tool to support granular label operations via a new method parameter, enabling atomic add/remove behavior without requiring a read-modify-write cycle.
Changes:
- Added
methodtoupdate_issue_labelswithreplace(default),add, andremovebehaviors, including URL-escaped label removal for names containing spaces/slashes. - Refactored label handling into helpers (
issueLabelNames,replaceIssueLabels,addIssueLabels,removeIssueLabels) and attached repo-visibility IFC labeling for label results. - Added unit tests and updated the tool snapshot and feature-flag docs to reflect the new input schema/behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/github/issues_granular.go | Adds method support and implements add/remove/replace label operations with validation and URL-escaped deletes. |
| pkg/github/helper_test.go | Adds mock endpoint patterns for the new labels POST and label DELETE routes used by tests. |
| pkg/github/granular_tools_test.go | Adds coverage for add/remove behaviors, trimming/dedup validation, escaping, and method normalization. |
| pkg/github/toolsnaps/update_issue_labels.snap | Updates the toolsnap to include the new method parameter and updated labels description. |
| docs/feature-flags.md | Updates feature-flag tool documentation to include the new method parameter and revised labels description. |
Merged
1 task done
This was referenced Nov 9, 2026
update_issue_labels is annotated destructiveHint: false but replaces (removes) existing labels
#3760
Open
6 of 7 tasks
Add a `method` parameter to the granular update_issue_labels tool so a
single tool can replace (default), add, or remove issue labels without
a read-modify-write cycle that can silently drop labels.
- add: POST /issues/{n}/labels, keeping existing labels
- remove: one DELETE /issues/{n}/labels/{name} per label, with the name
URL-escaped so names containing spaces or slashes stay one segment;
on failure the error lists labels already removed
- replace: unchanged PATCH behaviour, including per-label rationale,
confidence and is_suggestion intent
- label names are trimmed and validated for every method; add and
remove also de-duplicate names
The output keeps `id` and `url` and adds `labels`, the issue's labels
after the update, so callers see the resulting set without another read.
Mark the tool destructiveHint: true, since both replace and remove can
delete existing labels (github#3760).
Fixes github#2724
MayorFaj
force-pushed
the
feat/2724-improve-issue-label
branch
from
November 15, 2026 07:07
095bb42 to
11728ad
Compare
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.
Summary
Adds a
methodoption to the feature-flaggedupdate_issue_labelstool so one tool can replace (default), add, or remove an issue's labels.Why
Fixes #2724
The tool can only replace an issue's whole label set, so adding or removing one label means reading the current labels and sending back the full list. If that read is stale, labels are silently dropped. #2724 has a live repro: two agents each add a different label, and the first add is lost every time.
addandremovecall GitHub's add/remove label endpoints, so there is no read-modify-write and no lost labels.What changed
methodinput:replace(default),add,remove.replace: unchanged PATCH, including per-labelrationale/confidence/is_suggestion.add:POST /issues/{n}/labels, keeping existing labels.remove: oneDELETE /issues/{n}/labels/{name}per label. Names are URL-escaped, because go-github'sRemoveLabelForIssuedoes not escape names likestatus/blocked. If a removal fails part-way, the error lists the labels already removed.addandremovealso de-duplicate names.{id, url, labels}: the previousMinimalResponsefields plus the issue's labels after the update. Existing consumers ofid/urlare unaffected.destructiveHintset totrue, since bothreplaceandremovecan delete labels.MCP impact
methodinput, addslabelsto the output schema, and changesdestructiveHinttotrue. Only applies behind theissues_granularfeature flag. Calls withoutmethodbehave as before.Prompts tested (tool changes only)
Tested live against a private test repo with
--features=issues_granular, checking every step withgh:enhancementto issue 1":method: add, existing labels kept.good first issueandstatus/blockedfrom issue 1":method: remove. Names with a space and a slash work.add_label_to_issue/remove_label_from_issuetools #2724 scenario).[]: clears all labels.Security / limits
repo. The response now includes label names, so it is tagged with the repo-visibility IFC label (LabelRepoMetadata), the same as other tools that return labels.Tool renaming
Lint & tests
./script/lint./script/testDocs
docs/feature-flags.mdand the tool snapshot.Note: the default
issue_writetool also replaces the full label set whenlabelsis passed (see the repro in #2724). That is out of scope here and can be a follow-up.