Skip to main content

Module classify

Module classify 

Source
Expand description

Failure classification heuristics (RFC-029 §3.3).

The strategy, in priority order:

  1. Downcast fast-path — attempt to downcast to oxi-sdk structured error types. Today the typed ProviderError is stringified at the oxi-agent boundary, so this rarely succeeds. Kept for forward compatibility if upstream preserves the type in a future release.
  2. Cause-chain Display walk — collect every cause’s Display string, then pattern-match. The chain matters because the outermost anyhow::Error is often a wrapper like “Agent run failed” and the actual ProviderError Display is buried one or two levels deep (e.g. AgentError::RetriesExhausted { last_error }last_error: String).
  3. DefaultFailureClass::Unknown. Conservative: the coordinator will attempt one same-model retry, then escalate.

Patterns are matched case-insensitively against the lowercased concatenated cause chain. Keep them under test (this file’s #[cfg(test)] block) and review on oxi-ai upgrades — a provider changing its error wording degrades classification to Unknown, which is the safe fallback.

Functions§

classify
Classify an anyhow::Error into a FailureClass.