klieo-flows 3.4.0

Multi-agent composition shapes (Sequential / Parallel / Loop / Graph) for the klieo agent framework.
Documentation
//! Errors raised by `klieo-flows`.

use thiserror::Error;

/// Errors returned by [`crate::flow::Flow::run`] and its concrete impls.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum FlowError {
    /// An underlying [`klieo_core::Agent`] returned an error. Stringly
    /// typed because `Agent::Error` is associated and not erasable.
    #[error("agent error: {0}")]
    Agent(String),

    /// Marshalling between typed I/O and `serde_json::Value` failed.
    #[error("json marshalling: {0}")]
    Json(#[from] serde_json::Error),

    /// [`crate::loop_flow::LoopFlow`] exceeded `max_iters` or its predicate
    /// returned `LoopVerdict::Failed`.
    #[error("loop terminated: {reason} (iter {iter})")]
    Loop {
        /// Human-readable reason.
        reason: String,
        /// Iteration count at termination.
        iter: u32,
    },

    /// [`crate::graph::GraphFlow`] hit a cycle, missing node, or missing edge.
    #[error("graph error: {0}")]
    Graph(String),

    /// Underlying bus surfaced a transient failure during a flow.
    #[error("bus error: {0}")]
    Bus(#[from] klieo_core::error::BusError),

    /// A [`crate::flow::Flow`] dispatched a tool via
    /// [`klieo_core::tool::ToolInvoker`] and the invocation itself failed.
    /// Typed (rather than stringified) so callers can match
    /// [`klieo_core::error::ToolError::Cancelled`] /
    /// [`klieo_core::error::ToolError::Retryable`] and keep the source
    /// chain intact.
    #[error("tool error: {0}")]
    Tool(#[from] klieo_core::error::ToolError),

    /// The flow observed [`AgentContext::cancel`](klieo_core::agent::AgentContext)
    /// before starting an iteration / step and stopped without doing further
    /// work. Distinct from a body agent's own error so callers can tell a
    /// cooperative cancellation apart from a failure.
    #[error("flow cancelled")]
    Cancelled,
}