Middleware for loading and exposing agent skills to the system prompt.
Loads skills from backend sources and injects them into the system prompt using progressive disclosure (metadata first, full content on demand).
Skills are loaded in source order with later sources overriding earlier ones.
SkillsMiddleware(
self,
*,
backend: BACKEND_TYPES,
sources: list[str]
)Example:
from deepagents.backends.filesystem import FilesystemBackend
backend = FilesystemBackend(root_dir="/path/to/skills")
middleware = SkillsMiddleware(
backend=backend,
sources=[
"/path/to/skills/user/",
"/path/to/skills/project/",
],
)| Name | Type | Description |
|---|---|---|
backend* | BACKEND_TYPES | Backend instance for file operations |
sources* | list[str] | List of skill source paths. Source names are derived from the last path component. |
| Name | Type |
|---|---|
| backend | BACKEND_TYPES |
| sources | list[str] |
Inject skills documentation into a model request's system message.
Load skills metadata before agent execution (synchronous).
Loads skills once per session from all configured sources. If
skills_metadata is already present in state (from a prior turn or
checkpointed session), the load is skipped and None is returned.
Skills are loaded in source order with later sources overriding earlier ones if they contain skills with the same name (last one wins).
Load skills metadata before agent execution (async).
Loads skills once per session from all configured sources. If
skills_metadata is already present in state (from a prior turn or
checkpointed session), the load is skipped and None is returned.
Skills are loaded in source order with later sources overriding earlier ones if they contain skills with the same name (last one wins).
Inject skills documentation into the system prompt.
Inject skills documentation into the system prompt (async version).