-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
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.
Pull Request Overview
This pull request fixes executor hook functionality for plugins by generalizing hook execution to work across different services and moving command encoding to occur after plugin hooks are called.
- Refactored specific builder plugin hook check to support any plugin hooks through a generic
_call_ability_plugin_hooks
method - Added hook execution to the operations API manager to ensure plugins can modify abilities outside the planning service
- Moved command encoding to occur after plugin hooks to ensure hooks can modify abilities before encoding
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
app/service/planning_svc.py | Replaced specific builder plugin hook check with generic hook execution method |
app/api/v2/managers/operation_api_manager.py | Added plugin hook execution and moved command encoding after hooks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
app/service/planning_svc.py
Outdated
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.
This code will fail with an AttributeError if executor.HOOKS
is None or undefined. Add a null check before iterating: if executor.HOOKS:
before the for loop.
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 uses AI. Check for mistakes.
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.
This code will fail with an AttributeError if executor.HOOKS
is None or undefined. Add a null check before iterating: if executor.HOOKS:
before the for loop.
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 uses AI. Check for mistakes.
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) | ||
|
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 |
Copilot uses AI. Check for mistakes.
Can address the suggestions above and update the PR for approval |
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.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Description
This pull request addresses issues #3078 and #3079.
Currently there is a bug identified in #3078 that prevents the existing builder plugin from hooking the executor outside of the planning service. This is addressed by adding a similar check in the operations api manager.
Looking at the bigger picture, the executor hook check was specialized just for the builder plugin. The change below will parse through any hook that is added to the executor hook data structure allowing for other plugins to easily leverage this capability.
Type of change
How Has This Been Tested?
I have tested these changes on Caldera v5 with a plugin that leverages this hooking method to edit ability files before they are staged for an agent.
Checklist: