feat(plugins): improve plugin creation devex with @hook and @tool decorators#1740
Open
feat(plugins): improve plugin creation devex with @hook and @tool decorators#1740
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
d652f8e to
00f08ea
Compare
00f08ea to
655ffd3
Compare
655ffd3 to
f2f74e4
Compare
0d5b092 to
8519729
Compare
8519729 to
82b75cb
Compare
82b75cb to
cb098d6
Compare
mkmeral
approved these changes
Feb 27, 2026
|
|
||
| __all__ = [ | ||
| "Plugin", | ||
| "hook", |
Contributor
There was a problem hiding this comment.
nit: would it also make sense to export tool from here? I'm thinking the devx of:
from strands.plugins import Plugin, hook, tool
class MyPlugin(Plugin):
...I don't have a strong preference here though
|
|
||
| # Skip 'self' parameter for methods | ||
| first_param = params[0] | ||
| if first_param.name == "self" and len(params) > 1: |
Contributor
There was a problem hiding this comment.
Question: do we have validation check else where that hanldes edge cases like cls or self only method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, plugin authors must manually register hooks in their
init_plugin()method, which is verbose and error-prone:This PR enables declarative hook registration using a
@hookdecorator, making plugin development more intuitive and reducing boilerplate:Resolves: #1739
Public API Changes
New
@hookdecoratorThe
@hookdecorator marks methods for automatic registration: