feat: add hook_context kwarg to save_plugin_config and get_plugin_config extensible calls#1394
Open
Krashnicov wants to merge 1 commit intoagent0ai:developmentfrom
Open
Conversation
Collaborator
|
That does not make much sense to me. It's placed in get_plugin_config and will always produce "api" this way. |
Contributor
Author
|
Fixed — |
6fad084 to
a30972a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
hook_context: dictkwarg to bothcall_plugin_hook()call sites insave_plugin_config()andget_plugin_config()inhelpers/plugins.py.Motivation
Plugins intercepting these hooks have no way to distinguish the caller context (e.g. UI display vs. service layer vs. agent). Without this, plugins that need to behave differently per caller — for example, a secrets manager that masks values for the UI but resolves them for services — cannot do so without fragile
inspect.stack()hacks.hook_contextis a free-form dict passed as an additional kwarg. Existing plugin hooks that do not declare it receive it via**kwargsand are completely unaffected — fully backwards compatible.Example callers can pass:
{"caller": "ui"},{"caller": "service"},{"caller": "agent"}Change
Minimal —
hook_context=added to twocall_plugin_hook()invocations. No logic changes. No new dependencies. No existing behaviour altered.Backwards Compatibility
Fully backwards compatible. Plugin hooks not declaring
hook_contextreceive it silently via**kwargs.