Skip to content

Add optional rationale parameter to update_issue_type tool#2458

Open
alondahari wants to merge 1 commit into
mainfrom
alondahari/add-rationale-to-update-issue-type
Open

Add optional rationale parameter to update_issue_type tool#2458
alondahari wants to merge 1 commit into
mainfrom
alondahari/add-rationale-to-update-issue-type

Conversation

@alondahari
Copy link
Copy Markdown
Member

@alondahari alondahari commented May 12, 2026

Summary

Adds an optional rationale string parameter (max 280 chars) to the update_issue_type MCP tool, enabling agents to explain their classification decisions when setting an issue's type.

Motivation

Per the decision update on github/plan-track-agentic-toolkit#57, we're adding rationale directly to the upstream tool rather than as a remote-server-only override. This keeps the open-source tool schema in sync with the API contract while the API gracefully ignores the rationale when the server-side feature flag is disabled.

Why a standalone tool instead of using issueUpdateTool

The issueUpdateTool helper constrains handlers to returning a *github.IssueRequest, which only supports Type *string. When rationale is provided, the REST API expects the type field as an object ({"value": "...", "rationale": "..."}) rather than a plain string. Since go-github's IssueRequest struct can't represent this object form, we need to build a custom request body and use client.NewRequest/client.Do directly. Breaking out of the helper is the minimal change that enables the two serialization paths (string when no rationale, object when rationale is present) without modifying the shared helper or other tools that depend on it.

Once the API changes are stable and go-github is updated to support the object form natively, we intend to migrate this tool back to the shared issueUpdateTool helper.

Changes

  • pkg/github/issues_granular.go — Rewrote GranularUpdateIssueType as a standalone tool (no longer uses issueUpdateTool helper). When rationale is provided, sends the type as an object {"value": "...", "rationale": "..."} via a raw PATCH request. When omitted, sends {"type": "..."} preserving existing behavior.
  • pkg/github/granular_tools_test.go — Expanded test to table-driven covering both type-only and type-with-rationale cases.
  • pkg/github/__toolsnaps__/update_issue_type.snap — Updated schema snapshot.

Acceptance criteria

  • rationale is always in the schema (no feature-flag gating in this repo)
  • ✅ No behavioral change when rationale is omitted
  • ✅ Single API call passes both type and rationale when provided

Closes github/plan-track-agentic-toolkit#57

/cc @margaretmz

@alondahari alondahari force-pushed the alondahari/add-rationale-to-update-issue-type branch 3 times, most recently from c82dcb5 to 3b57894 Compare May 12, 2026 14:30
Add an optional `rationale` string parameter (max 280 chars) to the
`update_issue_type` MCP tool. When provided, the type is sent as an
object `{"name": "...", "rationale": "..."}` to the REST API,
enabling agents to explain their classification decisions. When omitted,
existing behavior is preserved (type sent as a plain string).

This supports the agent rationale experiment for type mutations. The
parameter is always visible in the schema — the API gracefully ignores
the rationale when the server-side feature flag is disabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alondahari alondahari force-pushed the alondahari/add-rationale-to-update-issue-type branch from 3b57894 to 2ce2ced Compare May 12, 2026 14:35
@alondahari alondahari marked this pull request as ready for review May 12, 2026 16:22
@alondahari alondahari requested a review from a team as a code owner May 12, 2026 16:22
Copilot AI review requested due to automatic review settings May 12, 2026 16:22
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

Adds an optional rationale parameter to the update_issue_type granular MCP tool so agents can provide a short explanation when setting an issue’s type, while preserving the existing request shape when rationale is omitted.

Changes:

  • Reworked update_issue_type to send either a string type field (no rationale) or an object type field with {value, rationale} (when rationale is present).
  • Expanded unit test coverage to validate both request payload shapes.
  • Updated the tool schema snapshot to include the new optional rationale field (maxLength 280).
Show a summary per file
File Description
pkg/github/issues_granular.go Reimplements update_issue_type as a standalone tool and adds request-body branching to support sending rationale.
pkg/github/granular_tools_test.go Adds table-driven tests to assert the outgoing PATCH body for type-only vs type-with-rationale.
pkg/github/toolsnaps/update_issue_type.snap Updates the tool input schema snapshot to include the optional rationale parameter.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

return nil, err
return utils.NewToolResultError(err.Error()), nil, nil
}
rationale, _ := OptionalParam[string](args, "rationale")
Comment on lines +393 to +399
var body any
if rationale != "" {
body = &issueTypeUpdateRequest{
Type: issueTypeWithRationale{
Value: issueType,
Rationale: rationale,
},
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