generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 650
Open
Description
Overview
Deprecate the hooks parameter on Agent and the HookProvider protocol in favor of plugins and Plugin, providing a clear migration path for users.
Parent Issue: #1636
Problem Statement
The HookProvider naming conflates the low-level hooks primitive with high-level agent extensions. Deprecating it in favor of Plugin provides clearer semantics.
Proposed Solution
Add deprecation warnings for:
- The
hooksparameter on Agent - Custom implementations of
HookProvider(excluding SDK built-ins)
Implementation Requirements
hooks Parameter Deprecation
# In Agent.__init__
if hooks:
warnings.warn(
"The 'hooks' parameter is deprecated. "
"Check out the docs to understand how to migrate to plugins: "
"https://strandsagents.com/latest/docs/plugins/",
DeprecationWarning,
stacklevel=2,
)
for hook in hooks:
self.hooks.add_hook(hook)HookProvider Deprecation
Add deprecation warning when HookProvider is subclassed, except for SDK built-in classes:
ConversationManagerand subclassesSessionManagerand subclassesModelRetryStrategySteeringHandler(until migrated)
Approach Options
Option A: Module-based detection
# In HookProvider or a helper
_SDK_MODULES = {
'strands.agent.conversation_manager',
'strands.session',
'strands.event_loop._retry',
'strands.experimental.steering',
}
def _is_sdk_class(cls):
return cls.__module__.startswith(tuple(_SDK_MODULES))Option B: Explicit registry
_EXEMPT_CLASSES = {
'ConversationManager',
'SessionManager',
'ModelRetryStrategy',
'SteeringHandler',
}Deprecation Warning Message
"HookProvider is now deprecated. Check out the docs to understand how to migrate to plugins: https://strandsagents.com/latest/docs/plugins/"
Files to Modify
src/strands/agent/agent.py- Add deprecation warning for hooks paramsrc/strands/hooks/registry.py- Add deprecation mechanism for HookProvidertests/strands/agent/test_agent.py- Test deprecation warningstests/strands/hooks/test_registry.py- Test HookProvider deprecation
Acceptance Criteria
- Deprecation warning shown when
hooksparameter is used - Deprecation warning shown when custom HookProvider is subclassed
- No warning for SDK built-in HookProvider implementations
- Unit tests verify warnings are raised appropriately
- Unit tests verify SDK classes don't trigger warnings
- Warning message includes link to migration docs
- Uses
DeprecationWarningcategory for proper filtering
Technical Notes
- No target removal version yet - this is a soft deprecation
hooksparameter continues to work, only acceptsHookProvider(notPlugin)- Built-in classes (SessionManager, etc.) will NOT be migrated to Plugin to avoid breaking customers
Dependencies
- Depends on: Plugin Protocol (1636.1), plugins parameter (1636.2)
- Should be done after: Documentation (1636.6) - so docs link is valid
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels