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