feat(tools): compress tool schemas and truncate descriptions#110
Open
juslintek wants to merge 1 commit intojwadow:mainfrom
Open
feat(tools): compress tool schemas and truncate descriptions#110juslintek wants to merge 1 commit intojwadow:mainfrom
juslintek wants to merge 1 commit intojwadow:mainfrom
Conversation
Adds opt-in tool schema compression to reduce token usage when many MCP tools are present. With 100+ tools (common with Claude Code), stripping verbose schema fields saves significant context window space. compress_json_schema() recursively strips: description, title, examples, $comment, markdownDescription from JSON Schema properties — keeping only structural fields needed for tool call generation. Long tool descriptions are also truncated to a configurable limit. Config: - KIRO_COMPRESS_TOOL_SCHEMAS=true (default) — enable schema compression - KIRO_TOOL_DESC_MAX_CHARS=200 (default) — max description length (0=disable)
|
Thanks for the PR! 🎉 Before merge, we need a one-time CLA confirmation. Full CLA text: Please reply once with: You need to write once, all further messages from me can be ignored. |
Author
|
I have read the CLA and I accept its terms |
Author has been inactive for a long time... Could you fork this repo and maintain it?! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds opt-in tool schema compression and description truncation to reduce token usage when many MCP tools are present.
Why
Claude Code with MCP servers can send 100+ tools per request. Each tool's JSON Schema includes verbose fields (description, title, examples, $comment, markdownDescription) that consume context window tokens but aren't needed for tool call generation. With 134 tools observed in live traffic, this saves thousands of tokens per request.
How
compress_json_schema()recursively strips verbose fields from JSON Schema properties, keeping only structural fields (type, properties, required, enum, items, etc.).Long tool descriptions are also truncated to a configurable limit.
Changes
config.py: AddKIRO_COMPRESS_TOOL_SCHEMAS(default: true) andKIRO_TOOL_DESC_MAX_CHARS(default: 200)converters_core.py: Addcompress_json_schema()function, integrate intoconvert_tools_to_kiro_format()Config
Testing
All 1413 existing tests pass. No dependencies on other PRs — this is independent.