#[non_exhaustive]pub enum AgentError {
Show 14 variants
ContextWindowOverflow {
model: String,
},
ModelThrottled,
NetworkError {
source: Box<dyn Error + Send + Sync>,
},
StructuredOutputFailed {
attempts: usize,
last_error: String,
},
AlreadyRunning,
NoMessages,
InvalidContinue,
StreamError {
source: Box<dyn Error + Send + Sync>,
},
Aborted,
Plugin {
name: String,
source: Box<dyn Error + Send + Sync>,
},
CacheMiss,
ContentFiltered,
SyncInAsyncContext,
RuntimeInit {
source: Error,
},
}Expand description
The top-level error type for the swink agent.
Each variant maps to a specific failure mode described in PRD section 10.3.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ContextWindowOverflow
Provider rejected the request because input exceeds the model’s context window.
ModelThrottled
Rate limit / 429 received from the provider.
NetworkError
Transient IO or connection failure.
StructuredOutputFailed
Structured output validation failed after exhausting all retry attempts.
AlreadyRunning
prompt() was called while a run is already active.
NoMessages
continue_loop() was called with an empty message history.
InvalidContinue
continue_loop() was called when the last message is an assistant message.
StreamError
Non-retryable failure from the StreamFn implementation.
Aborted
The operation was cancelled via a CancellationToken.
Plugin
An error from a plugin or extension.
CacheMiss
Provider-side context cache was not found (evicted or expired).
The framework resets CacheState
before consulting the configured retry strategy. Custom strategies can
choose to retry with CacheHint::Write.
ContentFiltered
Provider safety / content filter blocked the response.
Non-retryable — the input triggered a provider-side content policy. Callers can match on this variant to distinguish safety blocks from auth or network errors.
SyncInAsyncContext
A synchronous API (prompt_sync, continue_sync, etc.) was called
from within an active Tokio runtime.
These methods create their own Tokio runtime internally. Calling them
from async code (or any thread that already has a Tokio runtime) would
panic. Use the _async or _stream variants instead.
RuntimeInit
The internal Tokio runtime used by blocking sync APIs failed to start.
Implementations§
Source§impl AgentError
impl AgentError
Sourcepub const fn is_retryable(&self) -> bool
pub const fn is_retryable(&self) -> bool
Returns true for error variants that are safe to retry by default
(ModelThrottled and NetworkError).
Sourcepub fn network(err: impl Error + Send + Sync + 'static) -> Self
pub fn network(err: impl Error + Send + Sync + 'static) -> Self
Convenience constructor for AgentError::NetworkError.
Sourcepub fn stream(err: impl Error + Send + Sync + 'static) -> Self
pub fn stream(err: impl Error + Send + Sync + 'static) -> Self
Convenience constructor for AgentError::StreamError.
Sourcepub fn context_overflow(model: impl Into<String>) -> Self
pub fn context_overflow(model: impl Into<String>) -> Self
Convenience constructor for AgentError::ContextWindowOverflow.
Sourcepub fn structured_output_failed(
attempts: usize,
last_error: impl Into<String>,
) -> Self
pub fn structured_output_failed( attempts: usize, last_error: impl Into<String>, ) -> Self
Convenience constructor for AgentError::StructuredOutputFailed.
Sourcepub fn plugin(
name: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn plugin( name: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Convenience constructor for AgentError::Plugin.
Sourcepub const fn runtime_init(source: Error) -> Self
pub const fn runtime_init(source: Error) -> Self
Convenience constructor for AgentError::RuntimeInit.
Trait Implementations§
Source§impl Debug for AgentError
impl Debug for AgentError
Source§impl Display for AgentError
impl Display for AgentError
Source§impl Error for AgentError
impl Error for AgentError
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()
Auto Trait Implementations§
impl Freeze for AgentError
impl !RefUnwindSafe for AgentError
impl Send for AgentError
impl Sync for AgentError
impl Unpin for AgentError
impl UnsafeUnpin for AgentError
impl !UnwindSafe for AgentError
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.