-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
Reduce tool schema token overhead (~3,500 tok/session) #14785
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestNew feature or requestimpact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestNew feature or requestimpact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
Every session loads the full JSON schemas for all available tools into context. Currently this costs ~3,500 tokens (13,972 chars) — a fixed tax on every single session regardless of what the user is doing.
The biggest offenders by parameter count:
messagebrowsercronnodesProposed Improvements
1. Channel-aware schema filtering (biggest single win)
The runtime already knows which channel is active (e.g.
channel=telegram). Strip parameters that only apply to other channels. For example, on Telegram there is no need forguildId,autoArchiveMin,nsfw,roleIds,categoryId,threadName,rateLimitPerUser, and many other Discord/Slack-specific params.Estimated savings: ~800–1,000 tokens.
2. Lazy / on-demand tool loading
Only inject full schemas for tools that are likely to be used. For example:
browserschema only when web automation is discussednodesonly when device interaction comes up3. Move tutorials out of tool descriptions
The
crontool description contains a full tutorial on schedule types, payload types, delivery options, and constraints. This documentation could live in a skill file or docs page loaded on-demand rather than being baked into every session's context.4. Split mega-tools into sub-tools
Instead of one monolithic
messagetool with every possible action, consider splitting into focused sub-tools (message.send,message.react,message.delete, etc.) and only loading the ones relevant to the active channel and permissions.5. General description compression
Many tool descriptions repeat information that is already conveyed by parameter names and types. Tightening descriptions while keeping them model-readable could shave tokens across the board.
Impact
At ~3,500 tokens/session, this is a meaningful chunk of context — especially as conversations grow longer and every token counts. Even a 30–40% reduction would free up ~1,000–1,400 tokens per session across all users.
Environment