Skip to content

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
Krashnicov:feat/hook-context-plugin-config
Open

feat: add hook_context kwarg to save_plugin_config and get_plugin_config extensible calls#1394
Krashnicov wants to merge 1 commit intoagent0ai:developmentfrom
Krashnicov:feat/hook-context-plugin-config

Conversation

@Krashnicov
Copy link
Copy Markdown
Contributor

Summary

Adds an optional hook_context: dict kwarg to both call_plugin_hook() call sites in save_plugin_config() and get_plugin_config() in helpers/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_context is a free-form dict passed as an additional kwarg. Existing plugin hooks that do not declare it receive it via **kwargs and are completely unaffected — fully backwards compatible.

Example callers can pass: {"caller": "ui"}, {"caller": "service"}, {"caller": "agent"}

Change

Minimal — hook_context= added to two call_plugin_hook() invocations. No logic changes. No new dependencies. No existing behaviour altered.

Backwards Compatibility

Fully backwards compatible. Plugin hooks not declaring hook_context receive it silently via **kwargs.

@frdel
Copy link
Copy Markdown
Collaborator

frdel commented Apr 1, 2026

That does not make much sense to me. It's placed in get_plugin_config and will always produce "api" this way.

@Krashnicov
Copy link
Copy Markdown
Contributor Author

Fixed — hook_context is now assembled from a caller: CallerContext parameter (Literal["ui","agent","api"], default "api") on both get_plugin_config and save_plugin_config rather than hardcoded inside the function body. The default preserves full backwards compatibility — all existing call sites receive "api" implicitly without modification. Callers that need to distinguish context can pass the appropriate value explicitly.

@Krashnicov Krashnicov force-pushed the feat/hook-context-plugin-config branch from 6fad084 to a30972a Compare April 2, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants