AgentError is the central error type returned by most high-level operations in the framework, particularly those involving the Agent and AgentAir structs.
Definition
#[derive(Debug, Error)]
pub enum AgentError {
#[error("Configuration error: {0}")]
Config(#[from] ConfigError),
#[error("Controller error: {0}")]
Controller(#[from] ControllerError),
#[error("LLM provider error: {0}")]
Llm(#[from] LlmError),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Initialization failed: {0}")]
Init(String),
#[error("Task join error: {0}")]
JoinError(#[from] tokio::task::JoinError),
}
Usage
When building applications, you should typically wrap your main function or event loop logic to return Result<(), AgentError>. This allows you to catch any error bubbling up from the subsystems.
#[tokio::main]
async fn main() -> Result<(), AgentError> {
let agent = Agent::builder().build().await?;
agent.run().await?;
Ok(())
}
Conversions
AgentError implements From for all its sub-errors, making usage with the ? operator seamless.
