feat(skills): add agent skills as a plugin#1755
feat(skills): add agent skills as a plugin#1755mkmeral merged 33 commits intostrands-agents:mainfrom
Conversation
BREAKING CHANGE: Plugin is now an abstract base class instead of a Protocol. Plugins must explicitly inherit from Plugin and implement the abstract name property and init_plugin method. - Convert Plugin from @runtime_checkable Protocol to ABC - Make name an abstract property - Make init_plugin an abstract method - Update all tests to use inheritance - Maintain support for both sync and async init_plugin - All tests pass (1985 passed) 🤖 Assisted by the code-assist SOP
Implement the SkillsPlugin that adds AgentSkills.io skill support to the Strands Agents SDK. The plugin enables progressive disclosure of skill instructions: metadata is injected into the system prompt upfront, and full instructions are loaded on demand via a tool. Key components: - Skill dataclass with from_path classmethod for loading from SKILL.md - Loader module for discovering, parsing, and validating skills - SkillsPlugin extending the Plugin ABC with: - skills tool (activate/deactivate actions) - BeforeInvocationEvent hook for system prompt injection - AfterInvocationEvent hook for prompt restoration - Single active skill management - Dynamic skill management via property setter - Session persistence via agent.state Files added: - src/strands/plugins/skills/__init__.py - src/strands/plugins/skills/skill.py - src/strands/plugins/skills/loader.py - src/strands/plugins/skills/skills_plugin.py - tests/strands/plugins/skills/ (90 tests) Files modified: - src/strands/plugins/__init__.py (added SkillsPlugin export) - src/strands/__init__.py (added Skill to top-level exports)
- Create @hook decorator for declarative hook registration in plugins - Convert Plugin from Protocol to base class (breaking change) - Add auto-discovery of @hook and @tool decorated methods in Plugin.__init__() - Add auto-registration of hooks and tools in Plugin.init_plugin() - Support union types for multiple event types (e.g., BeforeModelCallEvent | AfterModelCallEvent) - Export hook from strands.plugins and strands namespaces - Update existing tests to use inheritance-based approach - Add comprehensive test coverage for new functionality BREAKING CHANGE: Plugin is now a base class instead of a Protocol. Existing plugins must inherit from Plugin instead of just implementing the protocol.
- Simplify skills tool to single activate action (remove deactivate/action param) - Capture original system prompt once instead of save/restore pattern - Remove AfterInvocationEvent hook (no longer needed) - Replace optional pyyaml with required dependency - Remove _parse_yaml_simple fallback parser - Export Skill and SkillsPlugin from strands top-level
Replace manual hook registration and standalone tool factory with declarative @hook and @tool decorators on SkillsPlugin methods. - Remove _make_skills_tool() standalone function - Convert skills() to @tool decorated instance method - Convert _on_before_invocation() to @hook decorated method - Remove register_hooks() (old HookProvider pattern) - Rename skills property to available_skills (avoids collision) - Delegate hook/tool registration to super().init_plugin() - Update tests to match new API surface
This reverts commit 29f9bf4.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Follow-up Review: Latest Commit ✅ Good progress! The new changes address key feedback: Changes in latest commit
The activation tracking is a nice addition that partially addresses sanjolia's multi-skill concern - while only one skill is "active" at a time for instruction loading, the agent state now tracks the full history of activated skills. Remaining items:
The implementation looks solid and ready for final approval once documentation is addressed. |
There was a problem hiding this comment.
Assessment: Request Changes
The implementation is excellent and all technical feedback has been addressed. However, the PR description still shows "Documentation PR: TBD" which needs to be resolved before merge.
Review Summary
Technical Implementation: ✅ Ready
- Clean plugin architecture following repository patterns
- Comprehensive test coverage (unit + integration)
- Lenient validation per AgentSkills.io spec
- Proper XML escaping and error handling
- Skill activation tracking for session persistence
Blocking Item:
- Documentation PR: The PR description states "TBD" under Documentation PR. Per repository guidelines, either:
- Link to a documentation PR at
https://github.com/strands-agents/docs/pull/... - Provide justification why documentation updates are not required
- Link to a documentation PR at
Once the documentation requirement is addressed, this PR is ready to merge. Great work on iterating through the feedback! 🎉
|
don't block on docs /strands review |
|
/strands review |
Co-authored-by: Nick Clegg <nac542@gmail.com>
Motivation
See design strands-agents/docs#528
This PR adds
SkillsPlugin, a first-class plugin that brings Agent Skills support to Strands. It follows the spec's progressive disclosure model: lightweight metadata (name + description) is injected into the system prompt at startup, and full instructions are loaded on-demand when the agent activates a skill via a tool call. This keeps context usage low while giving agents access to rich, task-specific instructions when needed.Public API Changes
New
SkillsPluginclass andSkilldataclass, both exported from the top-levelstrandspackage:The plugin registers a
skillstool that the agent calls to activate a skill by name. When activated, the tool returns the full instructions along with metadata (allowed tools, compatibility, location) and a listing of available resource files (scripts/,references/,assets/) for filesystem-based skills.Skills can be managed at runtime via a symmetric property and a resolution method:
Skill metadata is injected into the system prompt as XML before each invocation, with special characters escaped:
The active skill selection is persisted to
agent.statefor session recovery.Use Cases
Resolves: #1181
Documentation PR
TBD
Type of Change
New feature
Testing
Manually tested using jupyter notebook and set of skills from
anthropic/skillsrepository100 unit tests covering the plugin, tool, XML generation/escaping, response formatting, resource listing, session persistence, and skill resolution
2 integration tests against a real Bedrock model: model-driven skill activation with codeword verification, and direct tool invocation with state persistence checks
All existing tests (2145 total) continue to pass
I ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.