lmm_agent/error.rs
1// Copyright 2026 Mahmoud Harmouch.
2//
3// Licensed under the MIT license
4// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
5// option. This file may not be copied, modified, or distributed
6// except according to those terms.
7
8//! # Error types for `lmm-agent`.
9
10use thiserror::Error;
11
12/// Errors that can occur when building an [`crate::agent::LmmAgent`] via its
13/// builder.
14#[derive(Debug, Error)]
15pub enum AgentBuildError {
16 /// The `persona` field was not provided to the builder.
17 #[error("The `persona` field is required but was not set.")]
18 MissingPersona,
19
20 /// The `behavior` field was not provided to the builder.
21 #[error("The `behavior` field is required but was not set.")]
22 MissingBehavior,
23
24 /// A field value failed validation (e.g. empty string where one is required).
25 #[error("Field `{field}` failed validation: {reason}")]
26 InvalidField { field: &'static str, reason: String },
27}
28
29/// Errors that can occur during agent execution.
30#[derive(Debug, Error)]
31pub enum AgentError {
32 /// The agent has no assigned tasks.
33 #[error("Agent has no tasks to execute.")]
34 NoTasks,
35
36 /// A DuckDuckGo search failed.
37 #[error("Search error: {0}")]
38 Search(#[from] anyhow::Error),
39
40 /// Internal execution error with a custom message.
41 #[error("Execution failed: {0}")]
42 Execution(String),
43}
44
45// Copyright 2026 Mahmoud Harmouch.
46//
47// Licensed under the MIT license
48// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
49// option. This file may not be copied, modified, or distributed
50// except according to those terms.