pub struct ClassifierStrategy { /* private fields */ }Expand description
Chooses the opening candidate by asking a classifier model (ClassifierStrategy).
The model gets one closed question: the SDK’s routing rules and the routing policy, over a
bounded JSON routing context (the latest request, the agent’s textual instructions and each
candidate’s name, description and metadata under a positional key c0, c1, …). It must
answer through the forced structured-output tool. The context crosses the provider boundary,
so it must not contain secrets.
A single candidate is returned without asking; after an attempt the strategy declines, so a failure of the selected candidate surfaces. A failed, unknown or timed-out answer logs a warning and declines, and the router serves candidate zero.
Implementations§
Source§impl ClassifierStrategy
impl ClassifierStrategy
Sourcepub fn new(
model: impl Into<ModelSource>,
options: ClassifierStrategyOptions,
) -> Result<Self>
pub fn new( model: impl Into<ModelSource>, options: ClassifierStrategyOptions, ) -> Result<Self>
A strategy asking model, which must honor a forced tool choice: a model by value, an
Arc of one or a Bedrock model id, as the agent’s model(..) takes.
use std::sync::Arc;
use strands::models::routing::{ClassifierStrategy, ClassifierStrategyOptions};
use strands::testing::MockModel;
let by_value = ClassifierStrategy::new(MockModel::new(), ClassifierStrategyOptions::default())?;
let shared = ClassifierStrategy::new(Arc::new(MockModel::new()), ClassifierStrategyOptions::default())?;§Errors
A ModelRouter (model must be a Model or DecisionModel); a
Bedrock model id without the bedrock feature; a zero or too large timeout_ms; a zero
character limit.
Trait Implementations§
Source§impl Debug for ClassifierStrategy
impl Debug for ClassifierStrategy
Source§impl RoutingStrategy for ClassifierStrategy
impl RoutingStrategy for ClassifierStrategy
Auto Trait Implementations§
impl !RefUnwindSafe for ClassifierStrategy
impl !UnwindSafe for ClassifierStrategy
impl Freeze for ClassifierStrategy
impl Send for ClassifierStrategy
impl Sync for ClassifierStrategy
impl Unpin for ClassifierStrategy
impl UnsafeUnpin for ClassifierStrategy
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