pub enum InferenceError {
Transport(String),
Api {
status: u16,
body: String,
},
Deserialise {
message: String,
body: String,
},
MissingCredential {
provider: ProviderId,
},
NoAdapterRegistered {
provider: ProviderId,
},
Provider(String),
Unsupported(String),
MissingConfig(String),
}Expand description
Errors raised by an super::adapter::InferenceAdapter or the configurator.
Why: structured variants let the agent loop pattern-match on failure mode —
a 429 or a transport blip is retryable, a 401 or a missing credential is an
alarm — without parsing display strings.
What: transport, API (non-2xx), deserialisation, credential-resolution,
adapter-registration, provider-specific, and unsupported-capability variants.
Kept String-carrying (rather than #[from] reqwest::Error) so this
foundation crate stays free of a concrete HTTP dependency; #2403’s adapters
stringify their transport errors into Self::Transport.
Test: retryable_classification, alarm_classification.
Variants§
Transport(String)
The HTTP/transport layer failed (connection refused, TLS, timeout).
Api
The provider returned a non-2xx status.
Deserialise
The response body could not be deserialised into a super::ChatResponse.
Fields
MissingCredential
No credential could be resolved for the target provider.
Why: distinct from an API 401 — this fires before any network call, when
the configurator’s env/.env.local/store chain yields nothing.
Fields
provider: ProviderIdThe provider whose key could not be found.
NoAdapterRegistered
The configurator has no adapter factory registered for the resolved provider.
Why: the two-stage resolver picked a provider, but no adapter was wired in for it (in this foundation ticket only the test-support factory exists; real factories register in #2403).
Fields
provider: ProviderIdThe provider that resolved but has no factory.
Provider(String)
A provider-specific failure that does not fit the HTTP shapes (e.g. an AWS Bedrock SDK error).
Unsupported(String)
A requested capability is not supported by the target provider/model.
MissingConfig(String)
A required configuration value is missing, described in free text.
Why (#4425): Self::MissingCredential can only name a ProviderId
— it cannot carry an operator-actionable message, and it cannot describe
a missing NON-credential setting (an unset AWS region, an unconfigured
model slug, a test double with no scripted response left). trusty-code’s
former LlmError::MissingConfig covered exactly that ground, and its
migration onto this shared enum would otherwise have had to flatten
those messages into Self::Unsupported — whose display text
(“unsupported inference capability: OPENROUTER_API_KEY not set”) would
actively mislead the operator reading the log line.
What: a free-text description of what is missing. Classifies as an alarm
(a human must set something) and never as retryable, matching
Self::MissingCredential.
Test: missing_config_alarms_and_does_not_retry.
Implementations§
Source§impl InferenceError
impl InferenceError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the same call may succeed.
Why: the agent loop applies backoff+retry to transient failures only —
retrying a 401 or a schema mismatch just wastes budget.
What: true for Self::Transport and for Self::Api with a 429 or
any 5xx status; false otherwise.
Test: retryable_classification.
Sourcepub fn is_alarm(&self) -> bool
pub fn is_alarm(&self) -> bool
Whether this failure needs operator attention rather than a retry.
Why: config/auth/capability problems are dead-ends for automated retry —
surfacing them as alarms lets the caller stop and report instead of
spinning.
What: true for missing-credential, no-adapter-registered, unsupported,
and authentication/authorisation/not-found API statuses (401/403/404);
false otherwise.
Test: alarm_classification.
Trait Implementations§
Source§impl Debug for InferenceError
impl Debug for InferenceError
Source§impl Display for InferenceError
impl Display for InferenceError
Source§impl Error for InferenceError
impl Error for InferenceError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<InferenceError> for ToolCallExtractError
impl From<InferenceError> for ToolCallExtractError
Source§fn from(source: InferenceError) -> Self
fn from(source: InferenceError) -> Self
Source§impl From<InferenceError> for AgentLoopError
impl From<InferenceError> for AgentLoopError
Source§fn from(source: InferenceError) -> Self
fn from(source: InferenceError) -> Self
Auto Trait Implementations§
impl Freeze for InferenceError
impl RefUnwindSafe for InferenceError
impl Send for InferenceError
impl Sync for InferenceError
impl Unpin for InferenceError
impl UnsafeUnpin for InferenceError
impl UnwindSafe for InferenceError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more