pub struct ToolSelector { /* private fields */ }Expand description
Dynamic tool selector that loads tools based on conversation context.
Core tools (~18) are always available. Contextual tool groups activate when relevant keywords appear in recent messages and stay active for the remainder of the bout (monotonic growth) to maximize prompt cache hits.
The tool executor can still run ANY tool regardless of what the LLM sees —
capabilities are checked at execution time, not selection time. The model
never loses capability: shell_exec is always in the core set and can do
anything the contextual tools can via command-line equivalents.
Implementations§
Source§impl ToolSelector
impl ToolSelector
Sourcepub fn new(capabilities: &[Capability]) -> Self
pub fn new(capabilities: &[Capability]) -> Self
Create a new selector for a fighter with the given capabilities.
Groups whose capabilities are granted but have no representation in the
core tool set are auto-activated on construction. This prevents a
capability regression where, e.g., a fighter with SourceControl wouldn’t
get git tools on turn 1 unless the user explicitly said “git”.
Sourcepub fn select_tools(
&mut self,
messages: &[Message],
) -> (Vec<ToolDefinition>, bool)
pub fn select_tools( &mut self, messages: &[Message], ) -> (Vec<ToolDefinition>, bool)
Select tools based on conversation context.
Returns (tools, tools_changed) where tools_changed is true if the
tool list differs from the previous call (useful for cache invalidation
decisions).
Scans the last 4 messages (current + 3 prior) for keywords. Once a group activates, it stays active for the rest of the bout.
Sourcepub fn active_group_count(&self) -> usize
pub fn active_group_count(&self) -> usize
Return the number of currently active contextual tool groups.
Auto Trait Implementations§
impl Freeze for ToolSelector
impl RefUnwindSafe for ToolSelector
impl Send for ToolSelector
impl Sync for ToolSelector
impl Unpin for ToolSelector
impl UnsafeUnpin for ToolSelector
impl UnwindSafe for ToolSelector
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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