Conversation
- Add new docs/user-guide/concepts/plugins/index.md with comprehensive plugin documentation covering overview, basic usage, creating custom plugins, async initialization, advanced patterns, and best practices - Update mkdocs.yml navigation to include Plugins under Concepts - Update docs/community/get-featured.md to add Plugins category type - Update docs/user-guide/concepts/agents/hooks.md with: - Plugin recommendation tip at the top - Simplified agent.add_hook() API with type inference documentation - HookProvider vs Plugin comparison note - Add plugin recommendation tips to guardrails.md and retry-strategies.md - Update AGENTS.md directory structure to include plugins directory Resolves #568
| async def init_plugin(self, agent: "Agent") -> None: | ||
| # Perform async setup | ||
| self.config = await self.load_remote_config() | ||
| agent.add_hook(self.handler, BeforeToolCallEvent) |
There was a problem hiding this comment.
Issue: BeforeToolCallEvent is referenced on line 158 but not imported in this code example.
Suggestion: Add the import statement to the example:
import asyncio
from strands.plugins import Plugin
from strands.hooks import BeforeToolCallEvent # Add this importThere was a problem hiding this comment.
✅ This issue has been resolved. The async plugin example now properly imports BeforeToolCallEvent on line 269.
|
Assessment: Request Changes This PR adds comprehensive documentation for the Plugins feature. The documentation is well-structured with good use of diagrams, code examples, and cross-references. However, there are two issues that need attention before merging. Review Summary
The overall documentation quality is excellent - the plugins concept is clearly explained with practical examples and good guidance on when to use plugins vs hooks. 👍 |
build_output.log
Outdated
| @@ -0,0 +1,264 @@ | |||
|
|
|||
There was a problem hiding this comment.
Issue: This file appears to be accidentally committed build output.
Suggestion: Remove this file from the PR. It contains 264 lines of build logs that shouldn't be in the repository.
There was a problem hiding this comment.
There was a problem hiding this comment.
✅ Confirmed - this file has been removed in commit 246ff5f.
Documentation Deployment CompleteYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-573/ |
|
/strands can you update the docs to include the changes in this pull request: strands-agents/sdk-python#1739 |
Update plugins documentation to include: - @hook decorator for declarative hook registration - Event type inference from type hints - Union types for multiple event handlers - Auto-discovery of @tool decorated methods in plugins - Updated examples showing declarative approach - Guidance on when to use @hook vs manual registration - Multiple agents with same plugin instance pattern References strands-agents/sdk-python#1739
|
Assessment: Request Changes The documentation has been significantly improved with the addition of Remaining Issue
Once this file is removed, the PR should be ready to merge. The documentation is comprehensive and well-organized. 👍 |
|
Assessment: Request Changes (No changes since last review) The To remove it: git rm build_output.log
git commit -m "chore: remove accidentally committed build output"
git pushThe documentation content itself is ready to merge once this file is removed. |
Documentation Deployment CompleteYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-573/ |
build_output.log
Outdated
| agent = Agent() | ||
|
|
||
| # Register individual callbacks | ||
| # Register individual callbacks using the simplified API |
There was a problem hiding this comment.
| # Register individual callbacks using the simplified API | |
| # Register individual callbacks |
There was a problem hiding this comment.
Done - simplified the comment.
| You can also use the `agent.hooks.add_callback()` method for explicit event type specification: | ||
|
|
||
| === "Python" | ||
|
|
||
| ```python | ||
| agent = Agent() | ||
|
|
||
| def my_callback(event: BeforeInvocationEvent) -> None: | ||
| print("Custom callback triggered") | ||
|
|
||
| agent.hooks.add_callback(BeforeInvocationEvent, my_callback) | ||
| ``` | ||
|
|
||
| {{ ts_not_supported_code("This syntax is not yet available in TypeScript SDK") }} | ||
|
|
There was a problem hiding this comment.
Lets just not mention this
There was a problem hiding this comment.
Done - removed this section.
| !!! tip "Package as a Plugin" | ||
| If you want to share custom retry logic with others or reuse it across projects, consider packaging it as a [Plugin](../plugins/index.md). Plugins provide a clean interface for configuration and make your extensions easier to distribute. | ||
|
|
There was a problem hiding this comment.
Done - removed the tip.
| !!! tip "Consider Creating a Plugin" | ||
| If you plan to reuse this guardrails pattern across multiple agents or share it with your team, consider packaging it as a [Plugin](../concepts/plugins/index.md) for easier distribution and configuration. | ||
|
|
There was a problem hiding this comment.
Done - removed the tip.
| --8<-- "user-guide/concepts/agents/hooks.ts:hook_provider_class" | ||
| ``` | ||
|
|
||
| !!! note "HookProvider vs Plugin" |
There was a problem hiding this comment.
Lets remove this tip, and move mention of Hook Provider to the bottom of the page. You can replace this with a section that mentions that Plugins are a great way to provide multiple hooks to an agent. You can include a short code sample, and then point to the plugin page for more info.
There was a problem hiding this comment.
Done - removed the note, moved HookProvider to bottom of page, and added "Using Plugins for Multiple Hooks" section with code sample linking to plugins page.
|
|
||
| Hooks are a composable extensibility mechanism for extending agent functionality by subscribing to events throughout the agent lifecycle. The hook system enables both built-in components and user code to react to or modify agent behavior through strongly-typed event callbacks. | ||
|
|
||
| !!! tip "Consider Plugins for High-Level Behavior Changes" |
There was a problem hiding this comment.
Lets remove this top level tip. We mention it below.
There was a problem hiding this comment.
Done - removed the top-level tip.
| @@ -0,0 +1,503 @@ | |||
| # Plugins | |||
|
|
|||
| Plugins are a composable mechanism for extending agent functionality by encapsulating related hooks, configuration, and initialization logic into reusable packages. While [hooks](../agents/hooks.md) provide fine-grained control over agent lifecycle events, plugins offer a higher-level abstraction for packaging behavior changes that can be easily shared and reused. | |||
There was a problem hiding this comment.
Lets reword this to something like:
"Plugins allow you to change the typical behavior of an agent. They allow you to introduce concepts like Skills (https://agentskills.io/specification), steering, or other concepts into the agentic loop. Plugins work by taking advantage of the low-level primitives exposed by the agnet class: model, system_prompt, messages, tools, and hooks; and executing some logic to improve an agents behavior.
There was a problem hiding this comment.
Done - rewrote intro to mention Skills, steering, and how plugins work with agent primitives (model, system_prompt, messages, tools, hooks).
|
|
||
| Plugins are a composable mechanism for extending agent functionality by encapsulating related hooks, configuration, and initialization logic into reusable packages. While [hooks](../agents/hooks.md) provide fine-grained control over agent lifecycle events, plugins offer a higher-level abstraction for packaging behavior changes that can be easily shared and reused. | ||
|
|
||
| ## Overview |
There was a problem hiding this comment.
Lets link out to the sdk supported plugins here. Today its just steering, but more will come.
There was a problem hiding this comment.
Done - added Overview section with link to Steering as the current SDK-supported plugin.
|
|
||
| ## Overview | ||
|
|
||
| Plugins build on the hooks system to provide: |
There was a problem hiding this comment.
Lets create a section thats called something like "Building Plugins" that goes into the specifics of building an agent plugin. We can start with a short code example of what it looks like to add a logging plugin to an agent, then we can go step by step through how it works under the hood. This logging plugin can have two hook decorated methods, and a tool decorated method that will be attached to the agent. This can also show manual registration of these hooks and tools in the init_agent class.
Sections about saving state, and vending will also be useful.
There was a problem hiding this comment.
Done - created "Building Plugins" section with step-by-step guide including:
|
/strands |
Address review comments from Unshure: - Remove build_output.log accidentally committed file - Remove top-level plugin tip from hooks.md - Simplify hooks.md comment (remove 'simplified API') - Remove agent.hooks.add_callback() section from hooks.md - Remove plugin tips from guardrails.md and retry-strategies.md - Move HookProvider documentation to bottom of hooks.md - Add 'Using Plugins for Multiple Hooks' section to hooks.md - Rewrite plugins/index.md intro to mention Skills, steering, primitives - Add link to SDK supported plugins (Steering) in overview - Create 'Building Plugins' section with step-by-step guide - Add sections for state management and distributing plugins
Documentation Deployment CompleteYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-573/ |
|
Assessment: Approve ✅ All previous issues have been addressed and the author's feedback has been incorporated. Changes Verified
The documentation is well-organized with clear examples and good coverage of the plugin system. Ready to merge! 🚀 |
Summary
This PR adds comprehensive documentation for Plugins, a new composable mechanism for extending agent functionality in the Strands SDK.
Changes
New Documentation
docs/user-guide/concepts/plugins/index.md: Comprehensive plugin documentation covering:Agent(plugins=[...])@hookdecorator for declarative hook registration with event type inference@hookand@tooldecorated methodsPluginbase classNavigation Updates
mkdocs.ymlRelated Documentation Updates
docs/community/get-featured.md: Added Plugins as a new category type for community contributionsdocs/user-guide/concepts/agents/hooks.md:agent.add_hook()API with type hint inferencedocs/user-guide/safety-security/guardrails.md: Added tip about packaging guardrails as pluginsdocs/user-guide/concepts/agents/retry-strategies.md: Added tip about packaging retry logic as pluginsAGENTS.md: Updated directory structure to include the new plugins directoryTechnical Notes
{{ ts_not_supported_code() }}macros@hookdecorator feature from [FEATURE] Create@hookdecorator for Plugins sdk-python#1739Resolves #568