Skip to content

fix(server): trim tool and parameter descriptions under client context caps - #486

Merged
gaurav-singh-9227 merged 8 commits into
mainfrom
feat/trim-tool-descriptions
Oct 30, 2026
Merged

gaurav-singh-9227 merged 8 commits into
mainfrom
feat/trim-tool-descriptions

Conversation

@SavioBS629

@SavioBS629 SavioBS629 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Shortens tool and parameter descriptions so the full tool list fits in clients that cap it. Kiro, for example, renders every tool description into a single 30,000-character activation result and truncates anything longer; once truncated, the agent guesses tool names.

  • Tool descriptions keep to 200 characters; tools already over that are held at their trimmed length.
  • Parameter descriptions keep their constraints. Formats, enums, defaults and required fields are unchanged.
  • Rules that lived only in prose move into the schema: version keywords such as "newest", "most recent" and "earliest" now resolve to latest / oldest through a Zod .transform() (src/lib/version-keyword.ts).
  • Routing guidance agents depend on is kept: when paging stops, which page parameter to use, that no tool lists Test Management projects, and how askBrowserStackAI reports changes it could not confirm.

Measurements

Before After
Hosted tool set, rendered as Kiro renders it ~44,000 chars (truncated) ~29,600 chars
All tools, tool + parameter description text — ~21,200 chars

Guard

tests/tools/toolDescriptionBudget.test.ts now:

  • lowers the grandfathered per-tool ceilings to the trimmed lengths, and
  • caps total tool and parameter description text at 21,500 characters, so the list cannot grow back past the cap unnoticed.

Testing

  • npm run build (lint, format, tests, tsc) passes.
  • Every tool keeps the same name, input schema, required fields, defaults, enums and annotations; only the description text changes, plus the version-keyword transform.
  • Live, App Live, Automate and App Automate failure analysis, Accessibility, and Test Management flows run end to end in Kiro without truncation.

🤖 Generated with Claude Code

…t caps

Every client loads all tool descriptions at connect time. Kiro's power
activation renders them into one tool result capped at 30,000 chars; ours
was ~41,000, so Kiro truncated it to a 500-char preview and the agent
guessed tool names that do not exist.

Rewrites descriptions toward the documented budget (tool <=200 chars,
param <=120): shared precondition constants, standalone description
constants, and the capability-registry tools. Every routing rule is kept
(listProducts first, ask on a clash, describe before invoke, weak_match
re-search, '*' browse, paging, user_permission for writes, deletes
refused), and every phrase pinned by tests is unchanged.

Rendered size of the 44 hosted tools: 41,351 -> 27,512 chars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML (base), Organization UI (inherited), Workspace UI (inherited); Enforced overrides: Organization
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: a9d140c3-1432-4777-889a-cb145254aed5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@SavioBS629
SavioBS629 marked this pull request as draft October 14, 2026 14:08
Shorten Percy setup/scan parameter text and the createTestCase /
updateTestCase parameter text without changing their meaning.
Saves ~500 tokens on the 52-tool list.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sarve-shreyas
sarve-shreyas marked this pull request as ready for review October 21, 2026 10:40
SavioBS629 and others added 3 commits October 30, 2026 15:34
Conflicts resolved:
- tool-handoff.ts (a11y scan/config id hints), accessibility.ts
  (fetchAccessibilityIssues sources), applive.ts (dynamic description):
  took main; main's text is newer behaviour and already short.
- capability-registry/register.ts (invokeCapability): kept the trimmed
  wording and added main's new `select`/`narrowable` rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After merging main, the hosted tool set measured ~30,070 chars, just over
Kiro's 30,000 activation cap, mostly from the new accessibility report
sources and invokeCapability's `select`. Shortens those parameter
descriptions (fetchAccessibilityIssues, startAccessibilityScan,
invokeCapability, setupBrowserStackAppAutomateTests, askBrowserStackAI)
while keeping every source pointer and default.

Hosted set: ~29,340 chars. Local 52-tool set: ~32,760.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The trimmed descriptions dropped the prose telling the model to turn
"newest"/"most recent" into "latest" and "earliest"/"first" into
"oldest", and the code only matches those two exact strings. Move the
mapping into the schema with a shared versionString() (z.string()
.transform), as CLAUDE.md prefers, so it holds whatever the model sends.

Applied to runBrowserLiveSession (desiredOSVersion,
desiredBrowserVersion), runAppLiveSession and takeAppScreenshot
(desiredPlatformVersion). Matching is case- and whitespace-insensitive;
version numbers and names such as "Sequoia" pass through unchanged. The
advertised JSON schema is unchanged (type string, same description).

Verified over MCP: desiredOSVersion "newest" + desiredBrowserVersion
"most recent" resolve to Windows 11 / Chrome 156.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SavioBS629 and others added 2 commits October 30, 2026 17:47
…on budget

- searchCapability: paging stops when next_offset is absent
- invokeCapability: page with the capability's own parameter, not offset
- tool handoff: no tool lists projects, so use the capability functions
- askBrowserStackAI: read-only runs return changes in needs_approval
- setupPercyVisualTesting: only for projects that already have Percy
- updateTestCase: list cannot_be_automated again
- budget test: lower grandfathered ceilings to the trimmed lengths and
  cap total description text at 21,500 characters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaurav-singh-9227
gaurav-singh-9227 merged commit 5cd2019 into main Oct 30, 2026
8 checks passed
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