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.
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
limit: usizeThe 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: StringFNV-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.
Internal(String)
An unrecoverable internal error inside the loop implementation.