Skip to main content

otherone_agent/
error.rs

1// 作用:Agent 循环模块的错误类型
2// 关联:被 otherone-agent 内部使用
3
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum AgentError {
8    #[error("Invalid configuration: {0}")]
9    InvalidConfiguration(String),
10
11    #[error("Agent not found: {0}")]
12    AgentNotFound(String),
13
14    #[error("Agent call denied: {caller} -> {target}")]
15    AgentCallDenied { caller: String, target: String },
16
17    #[error("Agent call cycle detected: {0}")]
18    AgentCallCycle(String),
19
20    #[error("Maximum Agent call depth exceeded: {0}")]
21    MaxDepthExceeded(usize),
22
23    #[error("Runtime budget exceeded: {0}")]
24    BudgetExceeded(String),
25
26    #[error("Session already has an active writer: {0}")]
27    SessionBusy(String),
28
29    #[error("Agent run timed out")]
30    TimedOut,
31
32    #[error("Agent run cancelled")]
33    Cancelled,
34
35    #[error("AI error: {0}")]
36    AiError(#[from] otherone_ai::error::AiError),
37
38    #[error("Context error: {0}")]
39    ContextError(String),
40
41    #[error("Tool error: {0}")]
42    ToolError(String),
43
44    #[error("Storage error: {0}")]
45    StorageError(String),
46
47    #[error("Internal error: {0}")]
48    Internal(String),
49
50    #[error("Max iterations exceeded: {0}")]
51    MaxIterationsExceeded(u32),
52}