pub struct StageRouter { /* private fields */ }Expand description
Routes coding-agent turns between a capable and an efficient tier: tool signals decide first, an optional capability judge takes the turns they cannot, and the picker’s default tier closes the cascade so a turn is never left unrouted.
Implementations§
Source§impl StageRouter
impl StageRouter
Sourcepub fn new(
capable: LlmTarget,
efficient: LlmTarget,
config: StageRouterConfig,
) -> Result<Self>
pub fn new( capable: LlmTarget, efficient: LlmTarget, config: StageRouterConfig, ) -> Result<Self>
Routes between the capable and efficient targets. The
judge, when configured, is called through its own target and is not a
routing destination.
Errors if either threshold in config is outside [0.0, 1.0].
Trait Implementations§
Source§impl Algorithm for StageRouter
impl Algorithm for StageRouter
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.Auto Trait Implementations§
impl !Freeze for StageRouter
impl !RefUnwindSafe for StageRouter
impl Send for StageRouter
impl Sync for StageRouter
impl Unpin for StageRouter
impl UnsafeUnpin for StageRouter
impl !UnwindSafe for StageRouter
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