Proposal: Extensible hooks and plugin support #414
+2,166
−0
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
Introduces a design specification for an extensible hook system and plugin framework for Mellea. The hook system provides extension points across the framework's execution lifecycle — from session initialization through component execution, LLM generation, validation, sampling, and cleanup — enabling policy enforcement, observability, customization, and integrations without modifying core library code.
Specification Outline
on_<hook_name>), programmatic registration, or YAML configuration.Specification document
Implementation Plan
The implementation plan defines how Mellea's extensibility hook system will be built on top of the ContextForge plugin framework as an optional dependency. It introduces a new
mellea/plugins/subpackage containing aMelleaHookTypeenum along with Pydantic-based payload models, aMelleaPluginbase class with typed context accessors, and a lazy singletonPluginManagerwrapper with a centralinvoke_hook()helper guarded by three layers of no-op checks for zero overhead when plugins aren't configured. The plan details call sites across Mellea modules, specifying where each hook fires, what payload fields it carries, and whether it supports payload modification (e.g., rewriting model options or requirements) or is observability-only. Session-level configuration is exposed through new optional parameters onstart_session(), and the plugin framework dependency is gated behind try/except ImportError with an optional [plugins] install extra.Implementation plan
Review plan