pub struct AffinityRouter { /* private fields */ }Expand description
Retains a model per request identity and forces it on later matching requests.
Register the same instance as both a processor and a classifier; the two roles share the retained assignments through this instance’s interior storage. Decision events carry their originating request, so concurrent turns cannot bind one request’s identity to another request’s selected model.
with_latch_only narrows which models are retained — a
decision for any other model routes normally but is not latched (the escalation latch:
retain only the strong tier, never the weak one).
Implementations§
Source§impl AffinityRouter
impl AffinityRouter
Sourcepub fn for_subagents() -> Self
pub fn for_subagents() -> Self
Creates a router that retains assignments only for explicitly identified child agents.
Root-agent requests always abstain, so a later classifier selects them on every turn.
Sourcepub fn with_message_hash_fallback(self) -> Self
pub fn with_message_hash_fallback(self) -> Self
Uses the first user-message text as a fallback key when metadata has no session.
Sourcepub fn with_latch_only(
self,
models: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_latch_only( self, models: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Restricts latching to models; a decision for any other model routes but is not
retained.
Trait Implementations§
Source§impl<S> Classifier<S> for AffinityRouterwhere
S: Send + 'static,
impl<S> Classifier<S> for AffinityRouterwhere
S: Send + 'static,
Source§fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
request: &'life2 mut Request,
_driver: Option<&'life3 Driver>,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
request: &'life2 mut Request,
_driver: Option<&'life3 Driver>,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§impl Default for AffinityRouter
impl Default for AffinityRouter
Source§fn default() -> AffinityRouter
fn default() -> AffinityRouter
Source§impl<S> Processor<S> for AffinityRouterwhere
S: Send + 'static,
impl<S> Processor<S> for AffinityRouterwhere
S: Send + 'static,
Source§fn process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
event: Event<'life2>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
event: Event<'life2>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
state. Request-bearing events
(Event::Request, Event::Decision) may also be rewritten in place.