`src/error.rs` — `LoopError` and the poison policy
The single error enum for every framework operation, #[non_exhaustive], serde round-trippable, with retry answers built in.
Key items
LoopError— 20 variants; see the errors page for the full table with triggers.is_recoverable()— true forToolExecution,Api,ContextExceeded,Reflection,RateLimitEscalation.is_cancelled()— true only forCancelled.LoopError::tool_not_found(tool, available)— builds the capped availability list (10 names + “… (and N more)”).recover_guard(result)— force-recover a poisoned mutex guard; only for single-operation data (String, Vec, HashMap…).from_poison(what)— map a lock error toLockPoisoned { what }; for multi-field state machines.
Behavior notes
- The poison policy is two-handed: simple data gets recovered and the show goes on; state machines (fallback, detection, rate-limit) fail closed as
LockPoisonedwith a fixed label. Cancelledis a clean stop, not a failure — partial results may exist.ToolRecoveryExhausted.attemptscounts total calls (6 = original + 5 retries).
Deep dive: Errors.