Expand description
Classification of agent (Claude CLI) run failures into a small, stable taxonomy with a human-readable explanation.
classify() is a pure function: it takes the exit code, the
terminating signal, the tail of the child’s stderr, and an optional
terminal result frame, and returns an AgentFailure. It does no
IO and is exhaustively unit-tested against the real Anthropic error
phrasings, so the “why” behind a non-zero exit can be surfaced to the
user instead of a bare exit 1.
See docs/specs/SPEC_AGENT_FAILURE_DIAGNOSTICS_2026_06_11.md. This
is the P1 (capture + classify) slice; live-stream emission and UI
banners are P2/P3.
Structs§
- Agent
Failure - A classified agent failure: the class, a user-facing title + detail, the raw exit evidence, the stderr tail, and whether a retry is worth attempting.
Enums§
- Failure
Class - Stable failure taxonomy. Wire format is snake_case to match the rest
of the agent event surface (
frontend/types/srv-types.d.ts).
Functions§
- build 🔒
- capitalize_
provider 🔒 - Title-cases a raw provider id (“claude” -> “Claude”) for the spawn-gate message. reagent P2 on PR #2413: the raw lowercase slug read poorly next to catalog.ts’s real display names (“Claude Code”, “Gemini CLI”); this doesn’t reach for those (Rust has no access to the frontend catalog and duplicating/syncing the full display-name table across languages is disproportionate for one error string) — just enough prettification that the message reads as a proper noun.
- classify
- Classify an agent run failure.
- extract_
ambient_ 🔒home_ provider - Pulls the provider id out of
SpawnGateError::AmbientHomeDirNotAllowed’s own Display wording (“this agent’s {provider} identity points directly at your personal …” — identity/resolver/errors.rs). Same “return None on any mismatch rather than guessing” contract asextract_spawn_gate_providerabove. - extract_
claude_ 🔒md_ seed_ provider - Pulls the provider id out of
SpawnGateError::ClaudeMdSeedFailed’s own Display wording (“could not isolate this agent’s {provider} config directory (…): …”). - extract_
spawn_ 🔒gate_ provider - Pulls the provider id out of
SpawnGateError::MissingCredentials’s own Display wording (“no credentials for {provider}: the bound account was deleted or is unresolvable. Bind an account for this provider in Connectors → Accounts.” — identity/resolver/errors.rs). ReturnsNoneon any mismatch (e.g. that wording drifts) rather than guessing — callers fall back to generic phrasing instead of asserting a specific, possibly wrong, provider name. - first_
cli_ 🔒error - The first entry of a result frame’s
errorslist, where Claude Code puts its own failures before any turn (“No conversation found with session ID: …”). - frame_
error_ 🔒text - Best-effort error text from a terminal stream-json
resultframe:error.message, else a stringerror/result, else thesubtype. - frame_
or_ 🔒stderr_ line - The one line of
textthat carries a single-live-instance refusal, with any[AgentMux]prefix removed — the row’s detail. Falls back to the whole trimmed text. - is_
error_ 🔒result_ frame - True if a terminal
resultframe represents a failure. - mentions_
http_ 🔒status - True if
haymentions HTTP statuscodein a status-like context (e.g. “http 429”, “status 429”, “error 429”, “[429]”). Anchoring on a context word avoids the false positives a bare substring would hit — an ISO date like2026-04-29contains “429”. (reagent P2 on #1353.) - tail_
lines 🔒 - Last
max_linesnon-empty lines ofs, further capped to the lastmax_charscharacters (char-safe — never slices mid-codepoint).