pub struct ContextInjector { /* private fields */ }Expand description
Injects just-in-time context into the latest user message before each model call
(ContextInjector).
Before each model call the plugin asks its render callback for text, gated by the trigger, and
writes it into the latest user message as an InjectedBlock named after the plugin. The
block stays in the conversation and the session. A model that takes temporary messages
receives each block as a system message it reads until the next user message, so the stored
history is sent unchanged on every call; every other model receives only the latest user
message’s blocks, as text.
The block reaches the model input at once and the conversation when the model call ends
(before ModelMessageEvent hooks run); one injector serves one agent. Several injectors may
be registered; each contributes its text in plugin registration order.
Implementations§
Source§impl ContextInjector
impl ContextInjector
Sourcepub fn new(config: ContextInjectorConfig) -> Self
pub fn new(config: ContextInjectorConfig) -> Self
Creates the plugin.
Trait Implementations§
Source§impl Debug for ContextInjector
impl Debug for ContextInjector
Source§impl Plugin for ContextInjector
impl Plugin for ContextInjector
Source§fn init_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 mut LocalAgent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn init_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 mut LocalAgent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_tools(&self) -> Vec<ToolSource>
fn get_tools(&self) -> Vec<ToolSource>
init_agent:
anything that converts into a ToolSource, such as vec![MyTool.into()]. An MCP client
is rejected; pass it to the agent’s tools instead.Auto Trait Implementations§
impl !RefUnwindSafe for ContextInjector
impl !UnwindSafe for ContextInjector
impl Freeze for ContextInjector
impl Send for ContextInjector
impl Sync for ContextInjector
impl Unpin for ContextInjector
impl UnsafeUnpin for ContextInjector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more