1use hehe_core::error::Error as CoreError;
2use hehe_llm::LlmError;
3use hehe_tools::ToolError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum AgentError {
8 #[error("Configuration error: {0}")]
9 Config(String),
10
11 #[error("Session not found: {0}")]
12 SessionNotFound(String),
13
14 #[error("Max iterations reached: {0}")]
15 MaxIterationsReached(usize),
16
17 #[error("LLM error: {0}")]
18 Llm(#[from] LlmError),
19
20 #[error("Tool error: {0}")]
21 Tool(#[from] ToolError),
22
23 #[error("Core error: {0}")]
24 Core(#[from] CoreError),
25
26 #[error("Cancelled")]
27 Cancelled,
28
29 #[error("Internal error: {0}")]
30 Internal(String),
31}
32
33pub type Result<T> = std::result::Result<T, AgentError>;
34
35impl AgentError {
36 pub fn config(msg: impl Into<String>) -> Self {
37 Self::Config(msg.into())
38 }
39
40 pub fn internal(msg: impl Into<String>) -> Self {
41 Self::Internal(msg.into())
42 }
43}