pub trait Provider: Send + Sync {
// Required methods
fn descriptor(&self) -> ProviderDescriptor;
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<Result<ProviderEvent, ProviderError>>, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn capabilities(&self) -> ProviderCapabilities { ... }
fn fresh_session_scope(&self) -> Result<ProviderSessionScope, ProviderError> { ... }
fn fresh_conversation_scope(
&self,
) -> Result<ProviderSessionScope, ProviderError> { ... }
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Response, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: CompactionRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResponse, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn summarize_memories<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: MemorySummarizeRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<MemorySummarizeResponse, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Transport-neutral interface implemented by model providers.
Required Methods§
Sourcefn descriptor(&self) -> ProviderDescriptor
fn descriptor(&self) -> ProviderDescriptor
Returns identifying metadata for the provider instance.
Sourcefn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Lists models available from the provider.
Sourcefn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<Result<ProviderEvent, ProviderError>>, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<UnboundedReceiver<Result<ProviderEvent, ProviderError>>, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Streams a model response for the given request.
Provided Methods§
Sourcefn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Returns feature flags supported by this provider instance.
Sourcefn fresh_session_scope(&self) -> Result<ProviderSessionScope, ProviderError>
fn fresh_session_scope(&self) -> Result<ProviderSessionScope, ProviderError>
Returns the same configured provider with an independent session scope.
Scope creation is synchronous and local: it must not connect to the provider or perform other network I/O. Ordinary clones of the returned value share that one scope; calling this method again creates an independent one with the same descriptor identity.
Custom providers remain valid for one-shot runtimes without implementing this method. They report the capability as unsupported until they can separate reusable configuration from provider-owned session state.
Sourcefn fresh_conversation_scope(
&self,
) -> Result<ProviderSessionScope, ProviderError>
fn fresh_conversation_scope( &self, ) -> Result<ProviderSessionScope, ProviderError>
Returns the same configured provider with an independent conversation, still sharing this one’s transport.
The narrower half of fresh_session_scope,
under the same rules. It separates what answers questions about one
exchange — where its response chain is, which turn the endpoint routed
it to — and keeps what describes the endpoint, including any cached
connection. The runtime mints one of these per agent, so two agents
never read each other’s chain and still share one warm socket.
Custom providers remain valid without implementing this method; they report the capability as unsupported and the runtime keeps the scope it already had.
Sourcefn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Response, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: Request<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Response, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Sends a request and collects the full response in memory.
Sourcefn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: CompactionRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResponse, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn compact<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: CompactionRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<CompactionResponse, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Compacts transcript history using a provider-native endpoint when supported.
Sourcefn summarize_memories<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: MemorySummarizeRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<MemorySummarizeResponse, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn summarize_memories<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: MemorySummarizeRequest<'life1>,
) -> Pin<Box<dyn Future<Output = Result<MemorySummarizeResponse, ProviderError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Summarizes raw trace memories using a provider-native implementation when supported.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Provider for Arc<dyn Provider>
Forwards to the provider behind the pointer, so an Arc<dyn Provider> —
what the builtin provider constructors hand back — can be passed straight to
the generic P: Provider entry points.
impl Provider for Arc<dyn Provider>
Forwards to the provider behind the pointer, so an Arc<dyn Provider> —
what the builtin provider constructors hand back — can be passed straight to
the generic P: Provider entry points.