Skip to main content

zeph_agent_context/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Error types for the context-assembly service.
5
6use thiserror::Error;
7
8/// Errors that can occur during agent context-assembly operations.
9///
10/// The caller in `zeph-core` maps these variants to `AgentError` via a `From` impl.
11/// Each variant corresponds to one subsystem that the context service touches.
12#[derive(Debug, Error)]
13pub enum ContextError {
14    /// Memory backend returned an error during recall or summary loading.
15    ///
16    /// The agent should degrade gracefully — inject an empty recall section and continue.
17    #[error("memory error during context assembly: {0}")]
18    Memory(#[from] zeph_memory::MemoryError),
19
20    /// Context assembler in `zeph-context` returned an error.
21    #[error("context assembler error: {0}")]
22    Assembler(#[from] zeph_context::error::ContextError),
23
24    /// Serialization failed (e.g., building a JSON payload for the LLM).
25    #[error("serialization error: {0}")]
26    Serialize(#[from] serde_json::Error),
27
28    /// An operation timed out (e.g., spreading-activation recall, LLM probe).
29    #[error("operation timed out: {operation}")]
30    Timeout {
31        /// Short name of the operation that timed out.
32        operation: &'static str,
33    },
34
35    /// A required provider handle was absent (embedding or primary provider not configured).
36    #[error("provider not configured: {0}")]
37    ProviderMissing(&'static str),
38}