conversation_api/execution/error.rs
1//! Stable error semantics exposed by external ports.
2
3use serde::{Deserialize, Serialize};
4use thiserror::Error;
5
6/// Adapter-independent category used by Runtime policy and retry decisions.
7#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum ExternalErrorKind {
10 /// The request violates a contract or provider constraint.
11 InvalidRequest,
12 /// The caller or configured credential is not authorized.
13 Unauthorized,
14 /// The dependency is temporarily unavailable.
15 Unavailable,
16 /// The dependency rejected the request due to a rate limit.
17 RateLimited,
18 /// The selected model cannot accept the supplied context.
19 ContextLimit,
20 /// The run consumed more credits than its frozen admission budget.
21 CreditBudgetExceeded,
22 /// The operation exceeded its deadline.
23 Timeout,
24 /// The operation was cancelled by its owner.
25 Cancelled,
26 /// The adapter failed without a more specific stable classification.
27 Internal,
28}
29
30/// Sanitized error returned by LLM, App Facade, and event ports.
31#[derive(Clone, Debug, Error, Eq, PartialEq, Serialize, Deserialize)]
32#[error("{kind:?}: {message}")]
33pub struct ExternalError {
34 /// Stable machine-readable category.
35 pub kind: ExternalErrorKind,
36 /// Safe diagnostic message without credentials or infrastructure internals.
37 pub message: String,
38 /// Adapter-supplied retry delay when retrying is meaningful.
39 pub retry_after_ms: Option<u64>,
40}