pub struct LlmTaskClassifier { /* private fields */ }Expand description
Routes requests through a capability, escalation, or custom classifier mode.
Implementations§
Source§impl LlmTaskClassifier
impl LlmTaskClassifier
Sourcepub fn new(config: LlmClassifierConfig) -> Result<Self>
pub fn new(config: LlmClassifierConfig) -> Result<Self>
Builds the classifier mode described by config.
§Errors
Returns an error when the selected mode’s targets, contract, policy, or runtime settings are invalid.
Trait Implementations§
Source§impl Algorithm for LlmTaskClassifier
impl Algorithm for LlmTaskClassifier
Source§fn name(&self) -> &str
fn name(&self) -> &str
Stable, low-cardinality name identifying this algorithm — the
algorithm attribute on every span, metric, and log line the crate
emits for its runs.Source§fn count_tokens_client(&self) -> Option<Arc<dyn RoutedLlmClient>>
fn count_tokens_client(&self) -> Option<Arc<dyn RoutedLlmClient>>
The client
count_tokens forwards to: the first of
this algorithm’s targets whose client can count tokens (an Anthropic
upstream). The default is None — an algorithm with no Anthropic target
does not support token counting. Read moreSource§fn create_run_task<'async_trait>(
self: Arc<Self>,
ctx: Context,
driver: Driver,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
fn create_run_task<'async_trait>(
self: Arc<Self>,
ctx: Context,
driver: Driver,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
Run one request to completion: make model calls with
Driver::call_llm_target,
publish Decisions with Driver::info, and return the final Response.
The method an algorithm implements; run / run_stream
drive it. ctx carries the request’s cross-cutting values (today: the
algorithm’s telemetry label in Context::values).Source§fn process_signals<'async_trait>(
self: Arc<Self>,
signals: Signals,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
fn process_signals<'async_trait>(
self: Arc<Self>,
signals: Signals,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
Feed the algorithm agentic-stack events (tool results, budgets, etc.). The
reference algorithms ignore signals; a stateful algorithm updates its own
(interior-mutable) state. Takes
self: Arc<Self> like the other run methods.Source§fn count_tokens<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_tokens<'life0, 'async_trait>(
&'life0 self,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count the tokens
request would use — a direct passthrough to this
algorithm’s Anthropic target (via
count_tokens_client), not a routed
call. Token counting is a pre-flight estimate with no routing decision,
so it deliberately bypasses the classifier cascade (which runs only for
completions via run). Returns the upstream’s JSON
verbatim. Errors when the algorithm has no Anthropic target.Source§fn run_stream(
self: Arc<Self>,
ctx: Context,
request: Request,
observer: Option<RunObserver>,
) -> StepStream
fn run_stream( self: Arc<Self>, ctx: Context, request: Request, observer: Option<RunObserver>, ) -> StepStream
Source§fn run<'async_trait>(
self: Arc<Self>,
ctx: Context,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Arc<dyn Decision>>, Response)>> + Send + 'async_trait>>where
Self: 'async_trait,
fn run<'async_trait>(
self: Arc<Self>,
ctx: Context,
request: Request,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Arc<dyn Decision>>, Response)>> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn run_observed<'async_trait>(
self: Arc<Self>,
ctx: Context,
request: Request,
observer: Option<RunObserver>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Arc<dyn Decision>>, Response)>> + Send + 'async_trait>>where
Self: 'async_trait,
fn run_observed<'async_trait>(
self: Arc<Self>,
ctx: Context,
request: Request,
observer: Option<RunObserver>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<Arc<dyn Decision>>, Response)>> + Send + 'async_trait>>where
Self: 'async_trait,
Process a request to completion while reporting each model call to
observer.Source§impl Classifier<State> for LlmTaskClassifier
impl Classifier<State> for LlmTaskClassifier
Source§fn routing_tier(&self, selected_model: &str) -> Option<&'static str>
fn routing_tier(&self, selected_model: &str) -> Option<&'static str>
Stable tier represented by
selected_model, when this classifier defines one.Source§fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
state: &'life1 mut State,
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 State,
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
Auto Trait Implementations§
impl !Freeze for LlmTaskClassifier
impl !RefUnwindSafe for LlmTaskClassifier
impl Send for LlmTaskClassifier
impl Sync for LlmTaskClassifier
impl Unpin for LlmTaskClassifier
impl UnsafeUnpin for LlmTaskClassifier
impl !UnwindSafe for LlmTaskClassifier
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
Mutably borrows from an owned value. Read more