Skip to main content

ToolFactory

Trait ToolFactory 

Source
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§

Source

fn create_tool_registry( &self, enabled: &[&str], cwd: &Path, config: &Config, ) -> ToolRegistry

Build the registry for a new session.

  • enabled is the resolved tool-name allowlist after SessionOptions::enabled_tools and CLI defaults are merged.
  • cwd is the working directory the session opened in.
  • config is pi’s loaded Config, passed through so custom tools can read settings such as block_images without duplicating the config-loading logic.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§