pub trait ToolFactory: Send + Sync {
// Required method
fn create_tool_registry(
&self,
enabled: &[&str],
cwd: &Path,
config: &Config,
) -> ToolRegistry;
}Expand description
Hook for assembling the session’s ToolRegistry.
Attach an Arc<dyn ToolFactory> to SessionOptions::tool_factory
to inject custom tools, wrap the built-ins, or restrict the active
set. The factory runs once during create_agent_session, after
the tool-name allowlist has been resolved from
SessionOptions::enabled_tools.
To layer on top of the existing built-ins instead of starting from
scratch, call default_tool_registry from inside your impl and
register additional tools (or wrap existing ones) on the returned
registry.
Required Methods§
Sourcefn create_tool_registry(
&self,
enabled: &[&str],
cwd: &Path,
config: &Config,
) -> ToolRegistry
fn create_tool_registry( &self, enabled: &[&str], cwd: &Path, config: &Config, ) -> ToolRegistry
Build the registry for a new session.
enabledis the resolved tool-name allowlist afterSessionOptions::enabled_toolsand CLI defaults are merged.cwdis the working directory the session opened in.configis pi’s loadedConfig, passed through so custom tools can read settings such asblock_imageswithout duplicating the config-loading logic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".