pub struct ExtensionProviderHooks { /* private fields */ }Expand description
A ProviderHooks that dispatches to the registered extension handlers.
Keeps the cdylib mappings alive via the keepalive (the handler fn pointers
live inside the plugins).
Implementations§
Source§impl ExtensionProviderHooks
impl ExtensionProviderHooks
Sourcepub fn from_session(session: &ExtensionSession) -> Option<Self>
pub fn from_session(session: &ExtensionSession) -> Option<Self>
Build hooks over a loaded extension session’s registry snapshot. Returns
None when nothing needs this bridge (so a session without provider or
prompt hooks runs the plain no-op path).
Two independent reasons to install it, and both must be checked:
- Provider-hook tags — a plugin observing request/response. Includes
BeforeAgentStart, which is emitted from this bridge (seeSelf::before_request) because the harness never emits a prompt message event. before_agent_starttransformers — a plugin that replaces the system prompt. This is a separate slot, not an event subscription, so a plugin that only transforms the prompt registers no handlers at all; keying this check on the tags alone would skip the bridge and silently ignore its transform.
Trait Implementations§
Source§impl ProviderHooks for ExtensionProviderHooks
impl ProviderHooks for ExtensionProviderHooks
Source§fn transform_context(
&self,
_model: &Model,
ctx: &Context,
) -> Option<ContextPatch>
fn transform_context( &self, _model: &Model, ctx: &Context, ) -> Option<ContextPatch>
pi’s transform_context / before_agent_start-returns-systemPrompt:
let a plugin replace the prompt the request carries.
Computed once per prompt and cached, so every provider call of a run
(the tool loop) sees the same prompt — see
Self::last_forced_prompt. Returns None when no plugin registered a
transformer, when they all declined, or when the registry is stale, all
of which mean “leave the prompt alone”.
Source§fn before_request(
&self,
model: &Model,
ctx: &Context,
opts: &SimpleStreamOptions,
) -> Option<SimpleStreamOptionsPatch>
fn before_request( &self, model: &Model, ctx: &Context, opts: &SimpleStreamOptions, ) -> Option<SimpleStreamOptionsPatch>
Fan the planned request out to BeforeProviderRequest +
BeforeProviderHeaders subscribers. Returns None for the stream options
— observer-only (the event handler ABI has no result channel); a plugin’s
influence on the prompt travels through Self::transform_context
instead.
Source§fn after_response(&self, _model: &Model, message: &AssistantMessage)
fn after_response(&self, _model: &Model, message: &AssistantMessage)
Fan the terminal assistant message out to AfterProviderResponse
subscribers.