pub struct ToolRegistry { /* private fields */ }Expand description
A registry that holds multiple tools and implements ToolExecutor.
ToolRegistry provides a convenient way to manage multiple tools and
integrate them with the agent loop. It implements ToolExecutor so
it can be used directly with AgentLoop.
§Example
use everruns_core::tools::{Tool, ToolRegistry};
// Create registry and add tools
let mut registry = ToolRegistry::new();
registry.register(Box::new(GetCurrentTime));
registry.register(Box::new(GetWeather));
// Get tool definitions for agent config
let definitions = registry.tool_definitions();
// Use with agent loop
let agent_loop = AgentLoop::new(config, emitter, store, llm, registry);Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a tool registry with default built-in tools.
This includes:
get_current_time: Returns the current date and timeecho: Echoes back the provided messagereport_progress: Emits deterministic external progress updates- TestMath tools: add, subtract, multiply, divide
- TestWeather tools: get_weather, get_forecast
- TaskList tools: write_todos
- FileSystem tools: read_file, write_file, edit_file, list_directory, grep_files, delete_file, stat_file
- WebFetch tools: web_fetch — only when the
web-fetchcargo feature is enabled (on by default; absent in provider builds that disable core default features)
Sourcepub fn with_monitor_probe_defaults() -> Self
pub fn with_monitor_probe_defaults() -> Self
Create a tool registry for autonomous scheduled monitor probes.
Probe execution currently uses a scheduler-local ToolContext instead
of the fully populated worker/API executor context. Keep this registry to
context-free tools so scheduled probes cannot bypass session-scoped
controls such as network ACLs, egress routing, storage, or filesystem
mediation.
Sourcepub fn register(&mut self, tool: impl Tool + 'static)
pub fn register(&mut self, tool: impl Tool + 'static)
Register a tool with the registry.
If a tool with the same name already exists, it will be replaced.
Sourcepub fn register_boxed(&mut self, tool: Box<dyn Tool>)
pub fn register_boxed(&mut self, tool: Box<dyn Tool>)
Register a boxed tool
Sourcepub fn register_arc(&mut self, tool: Arc<dyn Tool>)
pub fn register_arc(&mut self, tool: Arc<dyn Tool>)
Register an Arc-wrapped tool
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Get all tool names
Sourcepub fn tool_definitions(&self) -> Vec<ToolDefinition>
pub fn tool_definitions(&self) -> Vec<ToolDefinition>
Get tool definitions for use in RuntimeAgent.
Returns a Vec of ToolDefinition that can be passed to
RuntimeAgent::with_tools().
Sourcepub fn validate_context_services(
&self,
services: &ToolContextServices,
) -> Result<()>
pub fn validate_context_services( &self, services: &ToolContextServices, ) -> Result<()>
Fail configuration before model exposure when a registered tool is missing a runtime service it declares as required.
Sourcepub fn unregister(&mut self, name: &str) -> Option<Arc<dyn Tool>>
pub fn unregister(&mut self, name: &str) -> Option<Arc<dyn Tool>>
Remove a tool from the registry
Sourcepub fn builder() -> ToolRegistryBuilder
pub fn builder() -> ToolRegistryBuilder
Create a builder for fluent tool registration
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§fn clone(&self) -> ToolRegistry
fn clone(&self) -> ToolRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolRegistry
impl Debug for ToolRegistry
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Source§impl ToolExecutor for ToolRegistry
impl ToolExecutor for ToolRegistry
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
_tool_def: &'life2 ToolDefinition,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
_tool_def: &'life2 ToolDefinition,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn execute_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
_tool_def: &'life2 ToolDefinition,
context: &'life3 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
_tool_def: &'life2 ToolDefinition,
context: &'life3 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn execute_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_calls: &'life1 [ToolCall],
tool_defs: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_calls: &'life1 [ToolCall],
tool_defs: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn execute_parallel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_calls: &'life1 [ToolCall],
tool_defs: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolResult>>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_parallel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_calls: &'life1 [ToolCall],
tool_defs: &'life2 [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolResult>>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request