use runifold_core::{BudgetExceeded, CheckpointError, JournalError};
use runifold_effect::EffectExecutorError;
use runifold_model::ModelError;
use runifold_retrieval::RetrievalError;
use runifold_tool::ToolError;
use thiserror::Error;
use crate::GatewayError;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum AgentError {
#[error("model invocation failed: {0}")]
Model(#[from] ModelError),
#[error("tool execution failed: {0}")]
Tool(#[from] ToolError),
#[error("agent retrieval failed: {0}")]
Retrieval(#[from] RetrievalError),
#[error("agent budget exceeded: {0}")]
Budget(#[from] BudgetExceeded),
#[error("agent delegation failed: {0}")]
Gateway(#[from] GatewayError),
#[error("agent observability failed: {0}")]
Journal(#[from] JournalError),
#[error("agent checkpoint failed: {0}")]
Checkpoint(#[from] CheckpointError),
#[error("agent effect failed: {0}")]
Effect(#[from] EffectExecutorError),
#[error("checkpoint contains an ambiguous in-flight turn {turn}")]
AmbiguousCheckpoint {
turn: u32,
},
#[error("invalid agent configuration: {0}")]
InvalidConfig(String),
#[error("agent protocol error: {0}")]
Protocol(String),
#[error("agent exceeded its local maximum of {max_turns} turns")]
MaxTurns {
max_turns: u32,
},
#[error("tool `{tool}` returned host-only output")]
ToolOutputNotVisible {
tool: String,
},
}