AgentError

Enum AgentError 

Source
pub enum AgentError {
    MaxIterationsReached(usize),
    LoopDetected {
        signature: String,
    },
    ParallelToolLimitExceeded {
        count: usize,
        limit: usize,
    },
    StagnationDetected {
        repeated_text_hash: String,
        count: usize,
        max_steps: usize,
    },
    Internal(String),
}
Expand description

Errors that terminate the agentic loop.

These represent conditions where AgentLoopPort::run cannot continue. They do not include tool execution failures — those are encoded as ToolResult { success: false } and fed back to the LLM as context.

Variants§

§

MaxIterationsReached(usize)

The loop reached AgentConfig::max_iterations without producing a final answer.

§

LoopDetected

The loop detected a repeated tool-call signature, indicating the model is stuck in a cycle.

The signature field is a stable hash of the tool-call batch that was repeated beyond AgentConfig::max_repeated_batch_steps.

Fields

§signature: String

Stable hash of the repeated tool-call batch (for diagnostics).

§

ParallelToolLimitExceeded

The LLM produced more tool calls in a single batch than configured by AgentConfig::max_parallel_tools.

This is a model protocol violation: the LLM returned more concurrent calls than the loop is configured to dispatch. The loop aborts rather than silently truncating the batch, because partial execution could leave the model with an incoherent view of which calls were handled.

Fields

§count: usize

Number of tool calls the LLM returned.

§limit: usize

The configured maximum (AgentConfig::max_parallel_tools).

§

StagnationDetected

The assistant produced the same text content for too many consecutive iterations, indicating a non-tool-calling repetition loop.

Preserves the FNV-1a hash of the repeated text, the total session-wide occurrence count (including baseline), and the configured max_stagnation_steps limit — giving callers structured access to the stagnation evidence without parsing an error string.

Detection is session-wide: both strictly consecutive repetitions and A → B → A oscillations are caught.

Fields

§repeated_text_hash: String

FNV-1a hash of the repeated assistant text, hex-encoded for diagnostics. Stored as String to decouple the public API from the internal u64 representation so callers never need to know the hashing algorithm.

§count: usize

Total number of times this text has been seen in the session (including the baseline occurrence).

§max_steps: usize

The configured stagnation limit at the time of detection.

§

Internal(String)

An unrecoverable internal error inside the loop implementation.

Trait Implementations§

Source§

impl Debug for AgentError

Source§

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

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

impl Display for AgentError

Source§

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

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

impl Error for AgentError

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

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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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