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
- Sending every MCP tool schema on every turn because "the model might need it."
- Including full JSON schemas for tools that are rarely used in the current workflow.
- Re-sending unchanged tool definitions after every model response.
See Also
- Operation Batching — batching reduces the per-turn cost of loading tools.
- Prompt Caching — tool definitions can be cached when they are stable.
- Context Isolation via Subagents — the same on-demand principle applied to data rather than to tool schemas.
- Progressive Disclosure — the same staged loading applied to instructions and skills rather than to tool schemas.
Tools
- GitHub Copilot tool search — loads tool definitions on demand instead of sending every full schema into context on every turn.
- MCP (Model Context Protocol) — protocol for tool and resource exposure; implementations can filter which tools are advertised per session.