Skip to content

Reduce context usage for list_tags#2088

Merged
kerobbi merged 2 commits intomainfrom
kerobbi/reduce-context-list-tags
Feb 25, 2026
Merged

Reduce context usage for list_tags#2088
kerobbi merged 2 commits intomainfrom
kerobbi/reduce-context-list-tags

Conversation

@kerobbi
Copy link
Contributor

@kerobbi kerobbi commented Feb 25, 2026

Summary

Reduces context usage for list_tags by introducing a new MinimalTag type.

Fields preserved

name, sha (flattened from nested commit.sha)

Fields dropped

commit (nested object with multiple sub-fields), zipball_url, tarball_url

Single Item Payload Diff

Before
{ "name": "v25.7.0", "commit": { "sha": "e7f5e71f3b71fba07bd94f758909fde4e58dc9e3", "url": "https://api.github.com/repos/nodejs/node/commits/e7f5e71f3b71fba07bd94f758909fde4e58dc9e3" }, "zipball_url": "https://api.github.com/repos/nodejs/node/zipball/refs/tags/v25.7.0", "tarball_url": "https://api.github.com/repos/nodejs/node/tarball/refs/tags/v25.7.0" } 
After
{ "name": "v25.7.0", "sha": "e7f5e71f3b71fba07bd94f758909fde4e58dc9e3" } 

Token Reduction

Measured using a script that makes use of OAI's tiktoken library (o200k_base) at 2 and 100 items. The web version can be found here.

Items Baseline Optimised Reduction
2 325 89 72.6%
100 15,858 4,192 73.6%

Why

list_tags was returning raw *github.RepositoryTag objects including a nested Commit object and download URLs. Only the tag name and commit SHA are useful for model reasoning, everything else is available via get_tag.

What changed

  • Added MinimalTag type and convertToMinimalTag conversion function
  • Wired convertToMinimalTag in list_tags
  • Updated relevant tests

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • List the last 2 tags in nodejs/node
  • List the last 100 tags in nodejs/node

Security / limits

  • No security or limits impact
  • 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
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

@kerobbi kerobbi requested a review from a team as a code owner February 25, 2026 14:42
Copilot AI review requested due to automatic review settings February 25, 2026 14:42
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 reduces token usage for the list_tags tool by introducing a new MinimalTag type that preserves only the essential fields (name and sha) and drops unnecessary fields like nested commit objects and download URLs. The implementation follows the established minimal types pattern used for other list operations (e.g., MinimalBranch, MinimalCommit). Token reduction measurements show approximately 73% fewer tokens with this change.

Changes:

  • Added MinimalTag type with name and sha fields
  • Added convertToMinimalTag() conversion function to transform GitHub API responses
  • Updated list_tags tool to return minimal tags instead of full repository tag objects
  • Updated tests to validate the new minimal type structure

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/github/minimal_types.go Added MinimalTag type definition and convertToMinimalTag() conversion function
pkg/github/repositories.go Updated ListTags handler to convert tags to minimal format before marshaling
pkg/github/repositories_test.go Updated test expectations to use MinimalTag instead of *github.RepositoryTag

@kerobbi kerobbi merged commit 391990a into main Feb 25, 2026
16 checks passed
@kerobbi kerobbi deleted the kerobbi/reduce-context-list-tags branch February 25, 2026 15:32
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.

3 participants