Skip to main content

llama_cpp_v3_agent_sdk/
error.rs

1use llama_cpp_v3::LlamaError;
2
3/// Unified error type for the agent library.
4#[derive(Debug, thiserror::Error)]
5pub enum AgentError {
6    #[error("Llama backend error: {0}")]
7    Llama(#[from] LlamaError),
8
9    #[error("Tool error: {tool}: {message}")]
10    Tool { tool: String, message: String },
11
12    #[error("Tool not found: {0}")]
13    ToolNotFound(String),
14
15    #[error("Failed to parse tool call from model output: {0}")]
16    ToolCallParse(String),
17
18    #[error("Permission denied for tool: {0}")]
19    PermissionDenied(String),
20
21    #[error("Max iterations ({0}) exceeded")]
22    MaxIterations(usize),
23
24    #[error("IO error: {0}")]
25    Io(#[from] std::io::Error),
26
27    #[error("JSON error: {0}")]
28    Json(#[from] serde_json::Error),
29
30    #[error("No model loaded")]
31    NoModel,
32
33    #[error("Agent error: {0}")]
34    Other(String),
35}