Skip to content

WIP: Add response optimisation for list_ tools#2016

Draft
kerobbi wants to merge 2 commits intomainfrom
kerobbi/response-optimisation
Draft

WIP: Add response optimisation for list_ tools#2016
kerobbi wants to merge 2 commits intomainfrom
kerobbi/response-optimisation

Conversation

@kerobbi
Copy link
Contributor

@kerobbi kerobbi commented Feb 16, 2026

Summary

Adds a response optimisation package that reduces token usage in list_ tool responses by applying six strategies: nested object flattening, URL elimination, zero-value elimination, whitespace normalisation, collection summarisation, and fill-rate filtering.

Two config mechanisms, preservedFields and collectionFieldExtractors, control which fields are exempt from optimisation and how nested collections are reduced.

Why

Current JSON responses are token heavy.

What changed

  • Added pkg/response/optimize.go - optimisation pipeline with two config mechanisms (preservedFields and collectionFieldExtractors)
  • Added tests covering all strategies and config interactions
  • Wired response.MarshalItems into list_pull_requests (remaining tools in progress)

MCP impact

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

Prompts tested (tool changes only)

  • WIP

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)

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