1use thiserror::Error;
2
3#[derive(Error, Debug)]
7pub enum AgentError {
8 #[error("Cascade inference failed: {0}")]
9 InferenceFailed(String),
10
11 #[error("Tool execution failed for '{tool}': {reason}")]
12 ToolFailed { tool: String, reason: String },
13
14 #[error("Context limit exceeded: {current} tokens (limit: {max})")]
15 ContextOverflow { current: usize, max: usize },
16
17 #[error("Skill error: {0}")]
18 SkillError(String),
19
20 #[error("Knowledge base error: {0}")]
21 KnowledgeError(String),
22
23 #[error("Orchestrator error: {0}")]
24 OrchestratorError(String),
25
26 #[error("Config error: {0}")]
27 ConfigError(String),
28
29 #[error("IO error: {0}")]
30 Io(#[from] std::io::Error),
31
32 #[error("Serialization error: {0}")]
33 Serialization(#[from] serde_json::Error),
34
35 #[error("Toml error: {0}")]
36 Toml(#[from] toml::de::Error),
37
38 #[error("Toml serialization error: {0}")]
39 TomlSer(#[from] toml::ser::Error),
40
41 #[error("Embedding error: {0}")]
42 EmbeddingError(String),
43
44 #[error("Tokenization error: {0}")]
45 TokenizerError(String),
46}
47
48pub type Result<T> = std::result::Result<T, AgentError>;