fix(hook): keep composite hooks backward compatible
Avoid AttributeError regressions when hooks define their own __init__ or when a CompositeHook wraps another composite. Made-with: Cursor
This commit is contained in:
1 parent
d88be08bfd
commit
6bf101c79b
3 files changed
+32
-1
No files matched your search
@@ -65,6 +65,7 @@ class CompositeHook(AgentHook):
|
||||
__slots__ = ("_hooks",)
|
||||
|
||||
def __init__(self, hooks: list[AgentHook]) -> None:
|
||||
super().__init__()
|
||||
self._hooks = list(hooks)
|
||||
|
||||
def wants_streaming(self) -> bool:
|
||||
@@ -72,7 +73,7 @@ class CompositeHook(AgentHook):
|
||||
|
||||
async def _for_each_hook_safe(self, method_name: str, *args: Any, **kwargs: Any) -> None:
|
||||
for h in self._hooks:
|
||||
if h._reraise:
|
||||
if getattr(h, "_reraise", False):
|
||||
await getattr(h, method_name)(*args, **kwargs)
|
||||
continue
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class _SubagentHook(AgentHook):
|
||||
"""Logging-only hook for subagent execution."""
|
||||
|
||||
def __init__(self, task_id: str) -> None:
|
||||
super().__init__()
|
||||
self._task_id = task_id
|
||||
|
||||
async def before_execute_tools(self, context: AgentHookContext) -> None:
|
||||
|
||||
Reference in new issue
Block a user