pub struct AdaptiveRegistry { /* private fields */ }Expand description
A tool registry that automatically limits the number of visible tools based on the configured model tier.
Small models get fewer tools (to fit smaller context windows), while large models get access to all registered tools.
Tool priority is determined by insertion order — tools registered first are selected first when the limit is applied.
find_tool() searches all tools regardless of tier limit, ensuring
tool execution always works even for tools beyond the active limit.
§Example
use traitclaw_core::registries::AdaptiveRegistry;
use traitclaw_core::traits::tool_registry::ToolRegistry;
use traitclaw_core::types::model_info::ModelTier;
let registry = AdaptiveRegistry::new(vec![], ModelTier::Medium);
assert!(registry.is_empty());Implementations§
Source§impl AdaptiveRegistry
impl AdaptiveRegistry
Sourcepub fn new(tools: Vec<Arc<dyn ErasedTool>>, tier: ModelTier) -> AdaptiveRegistry
pub fn new(tools: Vec<Arc<dyn ErasedTool>>, tier: ModelTier) -> AdaptiveRegistry
Create an adaptive registry with default tier limits.
Default limits: Small=5, Medium=15, Large=unlimited.
Sourcepub fn with_limits(
self,
small: usize,
medium: usize,
large: usize,
) -> AdaptiveRegistry
pub fn with_limits( self, small: usize, medium: usize, large: usize, ) -> AdaptiveRegistry
Override the default tier limits.
§Example
use traitclaw_core::registries::AdaptiveRegistry;
use traitclaw_core::types::model_info::ModelTier;
let registry = AdaptiveRegistry::new(vec![], ModelTier::Small)
.with_limits(3, 10, 50);Sourcepub fn limits(&self) -> TierLimits
pub fn limits(&self) -> TierLimits
Get the current tier limits.
Trait Implementations§
Source§impl ToolRegistry for AdaptiveRegistry
impl ToolRegistry for AdaptiveRegistry
Source§fn get_tools(&self) -> Vec<Arc<dyn ErasedTool>>
fn get_tools(&self) -> Vec<Arc<dyn ErasedTool>>
Returns at most limit tools based on the configured ModelTier.
Tools are returned in insertion order (first registered = highest priority).
Source§fn find_tool(&self, name: &str) -> Option<Arc<dyn ErasedTool>>
fn find_tool(&self, name: &str) -> Option<Arc<dyn ErasedTool>>
Searches all tools regardless of tier limit.
This ensures tool execution works even for tools beyond the active limit.
Source§fn register(&self, _tool: Arc<dyn ErasedTool>) -> bool
fn register(&self, _tool: Arc<dyn ErasedTool>) -> bool
true if the tool was added. Read moreSource§fn unregister(&self, _name: &str) -> bool
fn unregister(&self, _name: &str) -> bool
true if the tool was removed. Read moreSource§fn set_enabled(&self, _name: &str, _enabled: bool) -> bool
fn set_enabled(&self, _name: &str, _enabled: bool) -> bool
true if the state changed. Read more