1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum AgentError {
5 #[error("budget exhausted after {0} iterations")]
6 BudgetExhausted(u32),
7 #[error("transport error: {0}")]
8 Transport(#[from] TransportError),
9 #[error("tool error: {0}")]
10 Tool(#[from] ToolError),
11 #[error("context compression failed: {0}")]
12 Compression(String),
13 #[error("interrupted")]
14 Interrupted,
15 #[error(transparent)]
16 Other(#[from] anyhow::Error),
17}
18
19#[derive(Debug, Error)]
20pub enum TransportError {
21 #[error("HTTP error {status}: {body}")]
22 Http { status: u16, body: String },
23 #[error("rate limited, retry after {retry_after_secs}s")]
24 RateLimit { retry_after_secs: u64 },
25 #[error("network error: {0}")]
26 Network(String),
27 #[error("authentication failed")]
28 Auth,
29 #[error("model not found: {0}")]
30 ModelNotFound(String),
31 #[error("context length exceeded")]
32 ContextLengthExceeded,
33 #[error("stream error: {0}")]
34 Stream(String),
35 #[error("LLM call timed out after {0}s")]
36 Timeout(u64),
37 #[error(transparent)]
38 Other(#[from] anyhow::Error),
39}
40
41#[derive(Debug, Error)]
42pub enum ToolError {
43 #[error("tool not found: {0}")]
44 NotFound(String),
45 #[error("invalid arguments: {0}")]
46 InvalidArgs(String),
47 #[error("execution failed: {0}")]
48 Execution(String),
49 #[error("approval denied")]
50 ApprovalDenied,
51 #[error("tool '{0}' denied by active skill permissions")]
52 PermissionDenied(String),
53 #[error("tool timed out after {0}s")]
54 Timeout(u64),
55 #[error(transparent)]
56 Other(#[from] anyhow::Error),
57}
58
59#[derive(Debug, Error)]
60pub enum PlatformError {
61 #[error("connection error: {0}")]
62 Connection(String),
63 #[error("send failed: {0}")]
64 Send(String),
65 #[error("authentication failed")]
66 Auth,
67 #[error(transparent)]
68 Other(#[from] anyhow::Error),
69}