Expand description
Error types for the agent framework.
Every agent operation returns Result<T, [LoopError]>, and this
module defines the single unified error enum that carries structured
context for each failure mode. The variants are fine-grained enough
for callers to match on and recover programmatically
(see LoopError::is_recoverable), while still producing
human-readable messages via the thiserror #[error(...)]
attributes.
§Provided Types
LoopError— The sole error enum for the framework. Each variant wraps the relevant context (tool names, token counts, phase identifiers) so that diagnostics are precise without requiring callers to parse free-form strings.
§Quick Start
use loopctl::error::LoopError;
fn run_tool(tool: &str, available: &[&str]) -> Result<String, LoopError> {
if !available.contains(&tool) {
return Err(LoopError::tool_not_found(tool, available));
}
// invoke the tool
Ok("done".into())
}
fn main() {
match run_tool("search", &["read", "write"]) {
Ok(_) => println!("succeeded"),
Err(LoopError::ToolNotFound { tool, .. }) => {
eprintln!("unknown tool: {tool}");
}
Err(e) => println!("other error: {e}"),
}Enums§
- Loop
Error - Unified error type for the agent framework.