1use crate::traits::llm::LLMError;
4use crate::traits::storage::StorageCapability;
5use thiserror::Error;
6
7pub type Result<T> = std::result::Result<T, AgentError>;
9
10#[derive(Error, Debug)]
12#[non_exhaustive]
13pub enum AgentError {
14 #[error("Parse error: {0}")]
15 ParseError(String),
16
17 #[error("LLM error: {0}")]
18 LLMError(String),
19
20 #[error("Tool error: {0}")]
21 Tool(String),
22
23 #[error("Skill error: {0}")]
24 Skill(String),
25
26 #[error("LLM error: {0}")]
27 LLM(String),
28
29 #[error("Memory error: {0}")]
30 MemoryError(String),
31
32 #[error("Template error: {0}")]
33 TemplateError(String),
34
35 #[error("Configuration error: {0}")]
36 Config(String),
37
38 #[error("Invalid spec: {0}")]
39 InvalidSpec(String),
40
41 #[error("IO error: {0}")]
42 IoError(#[from] std::io::Error),
43
44 #[error("YAML error: {0}")]
45 YamlError(#[from] serde_yaml::Error),
46
47 #[error("JSON error: {0}")]
48 JsonError(#[from] serde_json::Error),
49
50 #[error("HITL timeout")]
51 HITLTimeout,
52
53 #[error("HITL rejected: {0}")]
54 HITLRejected(String),
55
56 #[error("Persistence error: {0}")]
57 Persistence(String),
58
59 #[error("Storage capability is not supported: {0}")]
60 UnsupportedStorageCapability(StorageCapability),
61
62 #[error("Memory budget exceeded: used {used} tokens, budget {budget} tokens")]
63 MemoryBudgetExceeded { used: u32, budget: u32 },
64
65 #[error("{0}")]
66 Other(String),
67}
68
69impl From<LLMError> for AgentError {
70 fn from(err: LLMError) -> Self {
71 AgentError::LLM(err.to_string())
72 }
73}