Skip to main content

InferenceError

Enum InferenceError 

Source
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),
    UnsupportedCapability {
        provider: ProviderId,
        capability: &'static str,
    },
    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.

Fields

§status: u16

HTTP status code.

§body: String

Raw response body (may be JSON or plain text).

§

Deserialise

The response body could not be deserialised into a super::ChatResponse.

Fields

§message: String

Human-readable parse error (never contains the API key).

§body: String

The raw body that failed to parse (aids debugging).

§

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: ProviderId

The 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: ProviderId

The 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.

§

UnsupportedCapability

The request asked for a capability the resolved provider does not have.

Why (#5588): Self::Unsupported carries free text, so a caller cannot tell WHICH provider refused WHICH capability without parsing the display string — and the structured-output path needs exactly that, because the recovery is “route this request to a provider that supports it”. Raised before any network call: a schema the provider cannot honour is a mis-routed request, not a completion to send and hope about. What: names the provider and the registry capability it lacks. Classifies as an alarm (route or configure differently) and never as retryable — the same provider will refuse the same request forever. Test: unsupported_capability_alarms_and_does_not_retry.

Fields

§provider: ProviderId

The provider that would have served the request.

§capability: &'static str

The registry capability the request needed, e.g. "structured_output".

§

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

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for InferenceError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for InferenceError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<InferenceError> for ToolCallExtractError

Source§

fn from(source: InferenceError) -> Self

Converts to this type from the input type.
Source§

impl From<InferenceError> for AgentLoopError

Source§

fn from(source: InferenceError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more