Skip to main content

pi_agent/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AgentError {
5    #[error("provider error: {0}")]
6    Provider(#[from] pi_ai::Error),
7
8    #[error("tool '{tool}' failed: {message}")]
9    Tool { tool: String, message: String },
10
11    #[error("agent cancelled")]
12    Cancelled,
13
14    #[error("agent reached max turns ({0})")]
15    MaxTurns(u32),
16
17    #[error("{0}")]
18    Other(String),
19}
20
21pub type Result<T> = std::result::Result<T, AgentError>;