Wink Pings

Claude Quickly Hits Context Limits With Too Many Tools: Ado Kukic Fixed It With Just Two Lines of Changes

When all tool definitions are stuffed into the context window, tokens are consumed at a fast rate, and the model's tool selection process also gets easily disrupted. Ado Kukic implemented a tool search feature, and set defer_loading: true for low-frequency tools. These two lines of configuration effectively save valuable context budget.

Ado Kukic shared a two-line tweak for Claude context management on X. The method is simple to implement: add tool_search_tool_bm25_20251119 to enable tool queries via natural language, or use its regex variant; then attach defer_loading: true to rarely used tools.

The background behind this fix is straightforward. Once Claude is connected to a large suite of tools, tool definitions will occupy a large portion of the context window upfront. When you stack MCP, agent functionalities, and various external capabilities, the context is already filled with tool descriptions before the model even starts handling actual tasks. This leads to rapid token consumption, and the model's tool selection is also prone to unnecessary interference.

The core idea behind this tweak is to turn the tool lookup process into a retrieval operation. tool_search_tool_bm25_20251119 uses the classic BM25 algorithm for tool search, so the model can query for required tools using natural language. BM25 ranks tool definitions by relevance, eliminating the need to dump all tool definitions into the context window all at once. Adding defer_loading: true to low-frequency tools enables deferred loading: their definitions are only imported into the context when they are actually needed.

This two-line configuration may seem minor, but its true value lies in context budget savings. The larger your tool set is, the more this operation feels like tidying up a storage closet: keep frequently used tools within easy reach, store rarely used ones away, and retrieve them only when required. This solution works best for agents with large tool collections and a high number of low-frequency tools. For scenarios with only a small set of frequently used tools, the gains will not be as obvious, so do not rush to roll this change out fully across all use cases. Evaluate your total tool count and tool invocation frequency first before deciding whether to apply the tweak.

Source: Ado Kukic's X Post, AIHOT Entry.

发布时间: 2026-12-05 06:50