1use runifold_core::{BudgetExceeded, CheckpointError, JournalError};
2use runifold_effect::EffectExecutorError;
3use runifold_model::ModelError;
4use runifold_retrieval::RetrievalError;
5use runifold_tool::ToolError;
6use thiserror::Error;
7
8use crate::GatewayError;
9
10#[derive(Debug, Error)]
12#[non_exhaustive]
13pub enum AgentError {
14 #[error("model invocation failed: {0}")]
16 Model(#[from] ModelError),
17 #[error("tool execution failed: {0}")]
19 Tool(#[from] ToolError),
20 #[error("agent retrieval failed: {0}")]
22 Retrieval(#[from] RetrievalError),
23 #[error("agent budget exceeded: {0}")]
25 Budget(#[from] BudgetExceeded),
26 #[error("agent delegation failed: {0}")]
28 Gateway(#[from] GatewayError),
29 #[error("agent observability failed: {0}")]
31 Journal(#[from] JournalError),
32 #[error("agent checkpoint failed: {0}")]
34 Checkpoint(#[from] CheckpointError),
35 #[error("agent effect failed: {0}")]
37 Effect(#[from] EffectExecutorError),
38 #[error("checkpoint contains an ambiguous in-flight turn {turn}")]
40 AmbiguousCheckpoint {
41 turn: u32,
43 },
44 #[error("invalid agent configuration: {0}")]
46 InvalidConfig(String),
47 #[error("agent protocol error: {0}")]
49 Protocol(String),
50 #[error("agent exceeded its local maximum of {max_turns} turns")]
52 MaxTurns {
53 max_turns: u32,
55 },
56 #[error(
58 "agent completed only {successful} successful local Tool calls; at least {required} required"
59 )]
60 ToolRequirementUnsatisfied {
61 required: u32,
63 successful: u32,
65 },
66 #[error(
68 "agent requires {required} successful local Tool calls but only {remaining} Tool calls remain in the shared budget"
69 )]
70 ToolRequirementExceedsBudget {
71 required: u32,
73 remaining: u64,
75 },
76 #[error("tool `{tool}` returned host-only output")]
78 ToolOutputNotVisible {
79 tool: String,
81 },
82}