Expand description
Tool registry for external tool integration with process lifecycle management.
The tools module provides a centralized registry for external tools (magellan, cargo, splice, etc.) that workflows can invoke by name. Tools are registered with their executable paths and default arguments, and can be invoked with additional arguments via ToolInvocation.
§Process Guards
The module implements RAII-based process lifecycle management through ProcessGuard, which automatically terminates spawned processes when dropped. This ensures proper cleanup even if errors occur during workflow execution.
§Example
ⓘ
use forge_agent::workflow::tools::{Tool, ToolRegistry, ToolInvocation};
let mut registry = ToolRegistry::new();
// Register a tool
let magellan = Tool::new(
"magellan",
"/usr/bin/magellan",
vec!["--db".to_string(), ".forge/graph.db".to_string()]
);
registry.register(magellan)?;
// Invoke the tool
let invocation = ToolInvocation::new("magellan")
.args(vec!["find".to_string(), "--name".to_string(), "symbol".to_string()]);
let result = registry.invoke(&invocation).await?;Structs§
- Chain
Fallback - Chain fallback handler that tries multiple handlers in sequence.
- Process
Guard - RAII guard for process lifecycle management.
- Retry
Fallback - Retry fallback handler with exponential backoff.
- Skip
Fallback - Skip fallback handler that returns a fixed result.
- Tool
- A registered external tool.
- Tool
Invocation - A specific tool invocation request.
- Tool
Invocation Result - Wrapper for tool invocation results with optional process guard.
- Tool
Registry - Registry for external tools.
- Tool
Result - Result of a tool invocation.
Enums§
- Fallback
Result - Result of a fallback handler operation.
- Tool
Error - Errors that can occur during tool operations.
Traits§
- Fallback
Handler - Handler for tool execution failures.