Skip to main content

ContextProvider

Trait ContextProvider 

Source
pub trait ContextProvider:
    Send
    + Sync
    + 'static {
    // Required method
    fn get_context_for_run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        runtime: &'life1 AgentRuntimeContext,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn get_context<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        agent_name: &'life1 str,
        tenant_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for injecting external context into agent calls.

Called before every LLM invocation with the agent name and tenant ID. Returns None if no external context is available.

Required Methods§

Source

fn get_context_for_run<'life0, 'life1, 'async_trait>( &'life0 self, runtime: &'life1 AgentRuntimeContext, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get context using the full runtime metadata when available.

Provided Methods§

Source

fn get_context<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, agent_name: &'life1 str, tenant_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get context for a specific agent and tenant.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§