Introducing Skill Search for Mastra Agents
Your Mastra agents can now load skills on demand with SkillSearchProcessor to reduce context bloat, token usage and cost.
The processor exposes two built-in tools:
search_skills: Finds matching skills by keyword using vector, bm25 or hybrid search.load_skill: Loads a skill’s instructions into the active thread.
By default, workspaces use a SkillsProcessor, which loads skills eagerly, exposing every skill to an agent on every turn. As a conversation progresses, context can become bloated, and token usage often increases. Now with a SkillSearchProcessor, skills load on demand: the agent searches for skills and only loads what it needs, keeping context windows smaller and reducing token usage.
When the agent needs a skill, it calls search_skills, finds matches, then uses load_skill to pull the instructions into context. Subsequent turns receive the same instructions. Loaded skills stay in thread state for a configurable TTL (default 1 hour) before they’re cleaned up. There’s a small latency cost for the first lookup of each skill, but following turns run with reduced token usage.