How LLM Agents Select & Load Skills from Disk
The fundamental challenge in building production agents: The LLM cannot know a skill exists unless it is in the request payload, but loading 100+ skills full-text crashes performance. Discover how agent systems solve this using Two-Tier Progressive Disclosure.
1 The Core Paradox (Context vs Discovery)
ConstraintIf an agent has 50 or 100 domain skills stored on disk (guidelines, personas, tool packages, prompt templates), loading all of them full-text into every API request creates severe bottlenecks:
-
✕
Context Window Bloat & High Cost:
50 detailed skills easily consume 40,000+ tokens per request, dramatically multiplying API costs.
-
✕
Time-To-First-Token Latency (TTFT):
Processing massive system prompts slows down pre-fill generation and response times.
-
✕
Instruction Noise & Rule Conflicts:
Loading dozens of irrelevant rules increases model hallucinations and tool misuse.
2 Two-Tier Progressive Disclosure Solution
ArchitectureInstead of loading all skill bodies upfront, agent frameworks split skill files into two distinct layers:
A lightweight manifest listing only the filename and a 1-sentence description.
• caveman.md: "Respond like smart caveman constraints" • market_intel.md: "Adds stock quote & FX conversion tools"
Complete markdown rules, persona constraints, and function schemas fetched from disk ONLY when Tier 1 matches user intent.
3 Pattern A: In-Loop Meta-Tool (`load_skill`)
Model-DrivenThe LLM operates as its own dynamic kernel. When the user prompt matches a description in the Tier 1 Catalog Index, the LLM emits a tool call to the skill loader:
tool_calls: [{ name: "load_skill", args: { skill_name: "caveman.md" } }]
- Application receives
load_skillrequest. - Application reads
skills/caveman.mdfrom local disk. - Application injects full text into Turn 2 system prompt payload.
4 Pattern B: Pre-LLM Semantic Router (RAG)
Framework-DrivenAgent frameworks (LangChain, AutoGen, LlamaIndex) run semantic similarity matching before sending the first prompt to the LLM:
embedding_search(user_prompt) ➔ matches ["caveman.md", "market_intel.md"]
- User query matched against vector store of skill descriptions.
- Relevant skills auto-injected into Turn 1 system prompt.
- LLM gets relevant skills instantly without needing a
load_skillturn.
API Serialization Reality: Why Tier 1 Catalog Lives Inside `system_prompt` Text
Standard API Spec
In standard LLM API specifications (OpenAI, Anthropic, Gemini), there is no native role: "catalog" message type. The API strictly recognizes four message roles: system, user, assistant, and tool.
Because no separate catalog role exists in the JSON schema, the Tier 1 Metadata Index is formatted as structured markdown text inside the system message string under a dedicated heading (e.g. AVAILABLE SKILLS CATALOG).