SkillSearchProcessor
The SkillSearchProcessor is an input processor that enables on-demand skill discovery and loading. Instead of injecting all skill metadata into the system prompt upfront (like SkillsProcessor), it gives the agent two meta-tools (search_skills and load_skill) that let it find and load skills on demand. This reduces context token usage when workspaces have many skills.
By default, when you attach only SkillSearchProcessor to an agent with a skill-enabled Workspace, the agent treats skills as on-demand:
- The default eager
SkillsProcessoris not auto-added. search_skillsandload_skillare exposed for discovery and instruction loading.- Overlapping
skillandskill_searchtools are hidden. skill_readremains available so the agent can read supporting skill files such as references, scripts, and assets.
If you explicitly configure SkillsProcessor alongside SkillSearchProcessor, the agent preserves the eager skill and skill_search tools as an opt-in path.
Usage exampleDirect link to Usage example
import { SkillSearchProcessor } from '@mastra/core/processors'
const skillSearch = new SkillSearchProcessor({
workspace,
search: {
topK: 5,
minScore: 0.1,
},
})
Constructor parametersDirect link to Constructor parameters
options:
workspace:
search?:
search.topK?:
search.minScore?:
ttl?:
ReturnsDirect link to Returns
id:
name:
providesSkillDiscovery:
processInputStep:
Extended usage exampleDirect link to Extended usage example
import { Agent } from '@mastra/core/agent'
import { SkillSearchProcessor } from '@mastra/core/processors'
import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
const workspace = new Workspace({
filesystem: new LocalFilesystem({ basePath: './project' }),
skills: ['skills'],
bm25: true,
})
const skillSearch = new SkillSearchProcessor({
workspace,
search: {
topK: 5,
minScore: 0.1,
},
})
const agent = new Agent({
name: 'skill-agent',
instructions:
'You are a helpful assistant. Use search_skills to find relevant skills, then load_skill to load their instructions.',
model: 'openai/gpt-4o',
workspace,
inputProcessors: [skillSearch],
})
The agent workflow is:
- Agent receives a user message
- Agent calls
search_skillswith keywords (e.g., "api design") - Agent reviews results and calls
load_skillwith the skill name - The skill's instructions appear as system messages on the next turn
- Agent follows the loaded skill's instructions
Workspace file toolsDirect link to Workspace file tools
SkillSearchProcessor loads skill instructions into the conversation. It does not block workspace file tools from reading files.
Use skill_read for supporting files that belong to a loaded skill, such as files under references/, scripts/, or assets/.
Reserve workspace file tools such as mastra_workspace_read_file for explicit file inspection or editing workflows. During normal task execution, the agent does not need to read the same SKILL.md file after load_skill succeeds.
Compared to SkillsProcessorDirect link to Compared to SkillsProcessor
| SkillsProcessor | SkillSearchProcessor | |
|---|---|---|
| Scaling | Injects all skills upfront | On-demand discovery |
| Context usage | Grows with skill count | Constant (only loaded skills) |
| Agent workflow | Skills always visible | Agent searches and loads as needed |
| Best for | Few skills (< 10) | Many skills (10+) |