Skip to content

Adding rationale for fields and labels in issues_granular#2505

Open
boazreicher wants to merge 6 commits into
mainfrom
boazreicher/add-rationale-to-update-labels-and-fields
Open

Adding rationale for fields and labels in issues_granular#2505
boazreicher wants to merge 6 commits into
mainfrom
boazreicher/add-rationale-to-update-labels-and-fields

Conversation

@boazreicher
Copy link
Copy Markdown

@boazreicher boazreicher commented May 19, 2026

Summary

Modifies the issues_granular tool to support adding rationales for changes to an issue's labels or fields.

Context

We decided that in order for our experiment to be more valuable we need to include these two other granular tools. We will not expand this capability beyond these tools before we decide to pursue this feature to GA and have a plan on implementation for all tools.

Why

Closes https://github.com/github/plan-track-agentic-toolkit/issues/156

What changed

  • Using the same approach as in Add optional rationale parameter to update_issue_type tool #2458

  • pkg/github/issues_granular.go — Rewrote GranularUpdateIssueLabels as a standalone tool (no longer uses issueUpdateTool helper). When rationale is provided, sends the labels as an object {"value": "...", "rationale": "..."} via a raw PATCH request. When omitted, sends {"type": "..."} preserving existing behavior. Also updated GranularSetIssueFieldss

  • pkg/github/granular_tools_test.go — Expanded test to table-driven covering both type-only and type-with-rationale cases.

  • Updated schema snapshots.

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 12:11
@boazreicher boazreicher requested a review from a team as a code owner May 19, 2026 12:11
Copy link
Copy Markdown
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 adds an optional per-item rationale parameter to two granular issue tools: update_issue_labels (REST) and set_issue_fields (GraphQL). Each rationale is capped at 280 characters and follows the same pattern previously introduced for update_issue_type in #2458, sending the rationale only when present so existing behavior is preserved.

Changes:

  • update_issue_labels is rewritten as a standalone tool that accepts either label name strings or {name, rationale} objects, building a raw PATCH request when any rationale is supplied and falling back to the standard github.IssueRequest{Labels: ...} wire format otherwise.
  • IssueFieldCreateOrUpdateInput gains a Rationale *githubv4.String and set_issue_fields accepts an optional per-field rationale (trimmed, ≤280 chars) that is forwarded in the GraphQL mutation.
  • Toolsnaps and tests updated, including table-driven tests for the new label shapes and an end-to-end test for a field with rationale plus length-validation cases.
Show a summary per file
File Description
pkg/github/issues_granular.go Rewrites GranularUpdateIssueLabels to support per-label rationale via raw PATCH; adds Rationale to IssueFieldCreateOrUpdateInput and schema/handler in GranularSetIssueFields.
pkg/github/granular_tools_test.go Table-driven coverage for plain/object/mixed labels, label validation errors, plus field rationale success and length-error cases.
pkg/github/toolsnaps/update_issue_labels.snap Schema snapshot updated to reflect the new oneOf string/object label item with rationale (max 280).
pkg/github/toolsnaps/set_issue_fields.snap Schema snapshot updated to include the new optional rationale field property.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

alondahari
alondahari previously approved these changes May 19, 2026
Copy link
Copy Markdown
Member

@alondahari alondahari left a comment

Choose a reason for hiding this comment

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

Looks good, just a comment on superfluous descriptions

Comment thread pkg/github/__toolsnaps__/update_issue_labels.snap Outdated
Comment thread pkg/github/__toolsnaps__/update_issue_labels.snap Outdated
boazreicher and others added 3 commits May 19, 2026 12:48
Co-authored-by: Copilot <copilot@github.com>
…ionale-to-update-labels-and-fields' into boazreicher/add-rationale-to-update-labels-and-fields
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.

5 participants