Skip to content

refactor(pull-requests): migrate consolidated PR tools to typed inputs and outputs - #3396

Draft
SamMorrowDrums wants to merge 1 commit into
sammorrowdrums-typed-search-toolsfrom
sammorrowdrums-typed-pull-request-tools
Draft

SamMorrowDrums wants to merge 1 commit into
sammorrowdrums-typed-search-toolsfrom
sammorrowdrums-typed-pull-request-tools

Conversation

@SamMorrowDrums

Copy link
Copy Markdown
Collaborator

Summary

Moves the consolidated pull request tools in pkg/github/pullrequests.go to NewTool[In,Out] with concrete inputs and output DTOs. Stacked on #3395.

Why

Continues the typed-output stack. Modern-protocol clients get schema-valid structuredContent, while legacy and unknown protocols get the same output as before.
Fixes #

What changed

  • Typed tools: pull_request_read, create_pull_request, update_pull_request, merge_pull_request, update_pull_request_branch, pull_request_review_write (both the default and the thread-resolution-reason variants), add_comment_to_pending_review and add_reply_to_pull_request_comment.
  • New consolidated_pull_request_types.go with:
    • Concrete inputs.
    • An explicit oneOf union for the pull_request_read methods, with a diff variant and a null variant.
    • Write, merge, branch and reply output DTOs, including the awaiting-form result and the reply/reaction union.
    • Legacy argument normalizers.
  • The legacy handlers never ran schema validation, so the normalizers repeat each handler's checks in the same order with the same error text. They also keep the legacy coercions:
    • numeric strings and whole floats;
    • review_write keys matched case-insensitively, plus its WeakDecode behaviour;
    • the commentId BigInt and < 1 errors;
    • "unknown method" errors;
    • the create form deferral when title/head/base are missing.
  • Legacy text output is byte-for-byte unchanged. structuredContent is sent only on 2026-07-28 and omitted on legacy and unknown protocols.
  • Tests in typed_consolidated_pull_request_outputs_test.go cover:
    • call and list on modern, legacy and unknown protocols;
    • the feature variant;
    • the awaiting form;
    • legacy error and coercion cases, checked against a probe of the parent c918f4b;
    • API errors;
    • schema resolution and conformance of zero values.
  • Updated toolsnaps, plus new _typed snapshots.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed — the 8 tools now declare an output schema. Input schemas and legacy text are unchanged.
  • New tool added

Prompts tested (tool changes only)

  • Covered by in-process MCP client tests rather than live prompts. Examples: "Get the diff/files/reviews of PR Port CLI Server #1", "Merge PR Port CLI Server #1 with squash", "Reply to review comment 42 with a heart reaction".

Security / limits

  • No security or limits impact — the same API calls, permissions and content filtering as before.
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint — passed (0 issues)
  • Tested locally with ./script/test — passed

Also run:

  • UPDATE_TOOLSNAPS=true go test ./... — passed
  • script/generate-docs — no doc changes
  • git diff --check — clean

Known CI: an inherited macOS flake from #3395 in typed_granular_issue_outputs_test.go:389 (the int64 overflow message differs on macOS).

Docs

  • Not needed — script/generate-docs produced no changes.
  • Updated (README / docs / examples)

…s and outputs

Convert pull_request_read, create_pull_request, update_pull_request,
merge_pull_request, update_pull_request_branch, pull_request_review_write
(both feature variants), add_comment_to_pending_review and
add_reply_to_pull_request_comment to NewTool with concrete inputs and
output DTOs. Input normalizers replay legacy handler checks so legacy
coercions and error text are preserved.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums
SamMorrowDrums added this pull request to stack #3385 October 2, 2026 14:33
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.

1 participant