Feature Request: Deferred Loading for Task Agents and Skills (like MCPSearch)
Summary
MCPSearch successfully defers MCP tool definitions until they're actually needed, saving significant context tokens. The same pattern should be applied to Task tool agent types and Skill tool skills, which currently load ~15,000+ tokens into every session whether used or not.
Problem
Every Claude Code session starts with:
- 100+ Task agent types with full descriptions (~10,000+ tokens)
- 60+ Skills with full descriptions (~5,000+ tokens)
These are always loaded, even if the user never spawns an agent or invokes a skill. This consumes ~15,000 tokens of the 200K context window (~7.5%) before the conversation even starts.
Proposed Solution
Implement AgentSearch and SkillSearch tools that follow the MCPSearch pattern:
AgentSearch
- List agent type names only in the system prompt (not full descriptions)
- When user needs an agent, search by keyword:
AgentSearch("code review")→ returns matching agent definitions - Only load the full agent config when actually spawning
SkillSearch
- List skill names only in the system prompt
- When user invokes a skill, search first:
SkillSearch("commit")→ loads full skill definition - Only load the skill instructions when actually invoking
Example
Current (always loaded):
"test-runner": use this agent after you are done writing code to run tests. This agent has access to Bash, Read, Write, Edit tools and specializes in...[500 more tokens of description]
Proposed (deferred):
Available agents: test-runner, code-reviewer, explore, plan, bash, security-manager...
Use AgentSearch("keyword") to load agent definitions on demand.
Impact
- ~15,000 tokens saved per session (~7.5% of context window)
- Users who don't use agents/skills get significant headroom back
- Users who do use them get the same functionality with on-demand loading
- Follows established MCPSearch pattern - no new UX to learn
Additional Context
MCPSearch already proves this pattern works well. The toolSearchThreshold setting successfully defers MCP tools. Extending this to Task agents and Skills would be a natural evolution of the same optimization.
---
Submitted via Claude Code
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗