Skip to main content

DefaultIntentRouter

Struct DefaultIntentRouter 

Source
pub struct DefaultIntentRouter { /* private fields */ }
Expand description

Default IntentRouter that scores registered tools against a token and returns the highest-ranked candidate’s route. Pure-data routing — no embeddings (the semantic CapabilityIndex lands in a separate slice); this router relies on verb match plus capability overlap.

Scoring (higher is better):

  • exact verb match (namespace + action) → +2.0
  • namespace-only match → +1.0
  • MCP coarse-verb fallback (mcp.<tool_name> matches the SIT’s action) → +0.5
  • Jaccard overlap of required_capabilities × tool.capabilities → × 1.5

When no tool clears 0.0, the router emits ToolRoute::HumanConfirm { ask } describing the unresolved verb — the pipeline surfaces that back to the user instead of guessing.

Implementations§

Source§

impl DefaultIntentRouter

Source

pub fn new(registry: Arc<dyn ToolRegistry>) -> Self

Source

pub fn with_breakers(self, breakers: Arc<dyn BreakerCheck>) -> Self

Wire a BreakerCheck so Open tools are excluded from scoring. Without one, every registered tool is considered.

Source

pub fn score(tok: &IntentToken, tool: &ToolDescriptor) -> f32

Score a single candidate against the token. Public so callers / tests can probe the ranking without invoking resolve.

Trait Implementations§

Source§

impl IntentRouter for DefaultIntentRouter

Source§

fn resolve<'life0, 'life1, 'async_trait>( &'life0 self, tok: &'life1 IntentToken, ) -> Pin<Box<dyn Future<Output = Result<ToolRoute, IntentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.