Token Efficiency Encyclopedia

Dynamic Tool Loading

Agents often have access to dozens of tools: file operations, terminal commands, MCP servers, workspace search, and product-specific actions. Sending every tool schema into the model context on every turn adds fixed overhead, even when only a small subset is relevant to the current task. GitHub Copilot addresses this by loading tool definitions dynamically instead of inlining the full schema of every available tool up front.

Principle

Load tool definitions on demand instead of inlining the full schema of every available tool up front. The model sees only the tools it needs, or a lightweight index from which it can request specific definitions.

Techniques

Tool Search

Provide the model with a searchable index of tool names and descriptions. When the model decides it needs a tool, it requests the full schema by name. The harness injects only that schema into the next turn. This keeps the per-turn context bounded regardless of total tool count. GitHub Copilot uses this approach to keep the available toolset broad while sending less unnecessary tool schema into the model.

Lazy Loading by Task Intent

If the agent knows the task type (e.g., "refactor code" vs. "run tests"), it pre-loads only the tool schemas known to be relevant to that task category. Other tools remain available but hidden until explicitly requested.

Hierarchical Tool Descriptions

Group tools into domains and send only top-level group descriptions. The model can drill down into a domain to retrieve individual tool schemas. This trades a small amount of extra round-trips for a large reduction in static context.

Trade-offs

Technique Context Reduction Extra Round-trips Complexity
Tool search High Low Medium
Lazy loading by intent Medium None Low
Hierarchical descriptions Medium Medium Medium

Anti-patterns

See Also

Tools