Problem Statement
add_callback() in registry.py returns None. Once a callback is registered, there is no mechanism to unregister it. TypeScript's addCallback() returns a HookCleanup function that removes the callback when called.
Use Case
Dynamic hook management during agent lifetime:
- Temporarily adding a logging hook for debugging, then removing it
- Plugins that register hooks on init and clean up on teardown
- Test fixtures that add hooks and need to clean up
Proposed Solution
Return a cleanup callable from add_callback():
def add_callback(self, event_type, callback):
self._callbacks[event_type].append(callback)
def cleanup():
self._callbacks[event_type].remove(callback)
return cleanup
Additional context
This was a finding from an agentic cross-SDK consistency scan between Python and TypeScript SDKs (strands-agents/sdk-typescript#789). The finding has been triaged, but verify that this needs an actual fix.
Problem Statement
add_callback()inregistry.pyreturnsNone. Once a callback is registered, there is no mechanism to unregister it. TypeScript'saddCallback()returns aHookCleanupfunction that removes the callback when called.Use Case
Dynamic hook management during agent lifetime:
Proposed Solution
Return a cleanup callable from
add_callback():Additional context
This was a finding from an agentic cross-SDK consistency scan between Python and TypeScript SDKs (strands-agents/sdk-typescript#789). The finding has been triaged, but verify that this needs an actual fix.