-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Plugin hook update #3101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Plugin hook update #3101
Changes from 10 commits
d1140f9
76b17e7
a06c97e
43f01ed
0afaf2a
9654088
858164c
4bca515
755f8f0
6e0cd12
f4be15b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -351,9 +351,7 @@ async def _generate_new_links(self, operation, agent, abilities, link_status): | |||||||||||
| executor = await agent.get_preferred_executor(ability) | ||||||||||||
| if not executor: | ||||||||||||
| continue | ||||||||||||
|
|
||||||||||||
| if executor.HOOKS and executor.language and executor.language in executor.HOOKS: | ||||||||||||
| await executor.HOOKS[executor.language](ability, executor) | ||||||||||||
| await self._call_ability_plugin_hooks(ability, executor) | ||||||||||||
| if executor.command: | ||||||||||||
| link = Link.load(dict(command=self.encode_string(executor.test), paw=agent.paw, score=0, | ||||||||||||
| ability=ability, executor=executor, status=link_status, | ||||||||||||
|
|
@@ -392,6 +390,11 @@ async def _generate_cleanup_links(self, operation, agent, link_status): | |||||||||||
| links.append(lnk) | ||||||||||||
| return links | ||||||||||||
|
|
||||||||||||
| async def _call_ability_plugin_hooks(self, ability, executor): | ||||||||||||
| """Calls any plugin hooks (at runtime) that exist for the ability and executor.""" | ||||||||||||
| for _hook, fcall in executor.HOOKS.items(): | ||||||||||||
| await fcall(ability, executor) | ||||||||||||
|
||||||||||||
| for _hook, fcall in executor.HOOKS.items(): | |
| await fcall(ability, executor) | |
| if executor.HOOKS: | |
| for _hook, fcall in executor.HOOKS.items(): | |
| await fcall(ability, executor) |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplicated hook execution logic in both files should be extracted to a shared utility or base class to avoid code duplication and ensure consistent behavior.
| async def _call_ability_plugin_hooks(self, ability, executor): | |
| """Calls any plugin hooks (at runtime) that exist for the ability and executor.""" | |
| for _hook, fcall in executor.HOOKS.items(): | |
| await fcall(ability, executor) | |
| # _call_ability_plugin_hooks is now implemented in BasePlanningService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code will fail with an AttributeError if
executor.HOOKSis None or undefined. Add a null check before iterating:if executor.HOOKS:before the for loop.