Skip to main content

Module tools

Module tools 

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

ChainFallback
Chain fallback handler that tries multiple handlers in sequence.
ProcessGuard
RAII guard for process lifecycle management.
RetryFallback
Retry fallback handler with exponential backoff.
SkipFallback
Skip fallback handler that returns a fixed result.
Tool
A registered external tool.
ToolInvocation
A specific tool invocation request.
ToolInvocationResult
Wrapper for tool invocation results with optional process guard.
ToolRegistry
Registry for external tools.
ToolResult
Result of a tool invocation.

Enums§

FallbackResult
Result of a fallback handler operation.
ToolError
Errors that can occur during tool operations.

Traits§

FallbackHandler
Handler for tool execution failures.