Skip to main content

AffinityRouter

Struct AffinityRouter 

Source
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

Source

pub fn new() -> Self

Creates a router that latches every decision.

Source

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.

Source

pub fn with_message_hash_fallback(self) -> Self

Uses the first user-message text as a fallback key when metadata has no session.

Source

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 AffinityRouter
where 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,

Score the classifier’s targets given the current state and request. Read more
Source§

fn routing_tier(&self, _selected_model: &str) -> Option<&'static str>

Stable tier represented by selected_model, when this classifier defines one.
Source§

impl Default for AffinityRouter

Source§

fn default() -> AffinityRouter

Returns the “default value” for a type. Read more
Source§

impl<S> Processor<S> for AffinityRouter
where 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,

Process an event, accumulating facts into state. Request-bearing events (Event::Request, Event::Decision) may also be rewritten in place.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,