Skip to content

docs(spec): failure evidence matrix per runtime (#227) - #230

Merged
xxchan merged 1 commit into
mainfrom
lookout/failure-evidence-matrix
Oct 8, 2026
Merged

xxchan merged 1 commit into
mainfrom
lookout/failure-evidence-matrix

Conversation

@xxchan

@xxchan xxchan commented Oct 8, 2026

Copy link
Copy Markdown
Member

First step of #227: the evidence matrix. No mapping or contract change yet; that's the follow-up PR.

What's here

  • docs/spec/runtime-matrix.md → "Failure evidence": what claude, codex, pi, opencode, kimi, grok, antigravity and cursor report for each cause, at open and in the turn:
    • causes: a missing login, an invalid key, an unknown or unentitled model, 429 throttling, a usage limit, a billing error, a 5xx, overload, an oversized context;
    • for each one: the native structured fields, retries, and the class oar 0.40 assigns today. Every cell carries an evidence level ([env], [rec], [src]/[sym], [doc]). The mapping will use only [env]/[rec] cells.
  • experiments/failure-evidence.ts: the probe behind it.
    • It runs the real CLIs (pi: the SDK) against a scripted provider (aimock). The provider answers with each vendor's documented error for the cause, from the Anthropic, OpenAI and Gemini (AIP-193) error references.
    • It also tests failures inside a 200 stream for claude, codex and pi: Anthropic's error event and the Responses API's response.failed.
    • cursor only runs with no key or a made-up one.
    • No real account is used and nothing is spent. One exception: codex's missing-login case sent an unauthenticated request to api.openai.com, which answered 401.
  • kimi.md, antigravity.md: a "known gap: a failed turn looks completed" note.

Findings that matter for the mapping

  • Structured causes:
    • claude: assistant.error plus result.api_error_status, and system/api_retry.
    • codex: codexErrorInfo plus httpStatusCode.
    • grok: retry_state.error_type, plus JSON-RPC -32003 for every 429.
  • Text only:
    • pi: errorMessage = " "; auto_retry_start is structured.
    • opencode: -32603 "Internal error: ", no status.
  • Failures reported as completed: kimi 2.1.1 answers every non-auth provider failure with stopReason: end_turn and no message. Its private wire.jsonl records the failure with a structured error. antigravity 1.3.0 does the same for most failures.
  • Classes oar gets wrong today:
    • claude's "credit balance too low" (billing_error) → unknown;
    • codex serverOverloaded and contextWindowExceeded → unknown;
    • claude's oversized context → unknown.

Verification

An independent cross-check compared every cell with the raw run records (one JSON file per case). It found 8 imprecisions, which are fixed here. Typecheck and lint pass. The change is docs plus one experiment script, so no tests change.

🤖 Generated with Claude Code

What claude, codex, pi, opencode, kimi, grok, antigravity and cursor report
when a session fails for a missing login, an invalid key, an unknown or
unentitled model, a 429, a usage limit, a billing error, a 5xx, overload or
an oversized context, at open and in the turn, with each cell's evidence
level. The first step of #227: no mapping yet.

experiments/failure-evidence.ts runs the real runtimes against a scripted
provider (aimock) answering with each provider's documented error, plus
failures inside a stream for claude, codex and pi; cursor only with no key
or a made-up one. No real account is used and nothing is spent.

Notable: claude, codex and grok carry structured causes (assistant.error
and api_error_status; codexErrorInfo; retry_state.error_type and -32003);
pi and opencode carry text; kimi 2.1.1 and antigravity 1.3.0 answer most
failed prompts end_turn, so oar records them completed (noted on their
pages as a known gap).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 2ae9f67 into main Oct 8, 2026
13 checks passed
@xxchan
xxchan deleted the lookout/failure-evidence-matrix branch October 8, 2026 06:39
xxchan added a commit that referenced this pull request Oct 8, 2026
Closes #227 (second step; the evidence matrix was #230).

## What changes

**Contract (additive)**
- `FailureClass` gains `model_unavailable`, `input_too_large`,
`rate_limited` and `billing`.
- A failed `TurnOutcome` gets two optional fields, set only where the
runtime says them:
  - `credential`: `"missing" | "rejected"`;
  - `status`: the provider's HTTP status.
- New `RuntimeFailureError { failure, credential?, status?, reason }`.
`session()` rejects with it when the open fails for one of these causes:
  - ACP -32000 on initialize, authenticate, new or resume → `auth`;
  - a -32602 answer to the model call → `model_unavailable`;
  - cursor's `AuthenticationError` → `auth`, `rejected`;
  - a pi model oar doesn't find → `model_unavailable`.
- `observe`:
- `failureAdvice(failure)` returns `{ retry: "now" | "later" | "no",
userAction }`;
- `failureText(failure, runtimeName, credential?)` covers the new
classes.

**Mapping.** Each adapter reads the runtime's own category first, then
the provider error body (`code`, then `type`), then the HTTP status.
Matching words is each adapter's documented last resort.

| runtime | reads |
|---|---|
| claude | `assistant.error`, then `api_error_status` /
`terminal_reason`; the 400 spend limit by its words |
| codex | `codexErrorInfo`, including the transport variants'
`httpStatusCode`; for `other`, the code in the provider's JSON body |
| pi | `errorMessage`: the status prefix and the JSON body; pi-ai's
`isContextOverflow` |
| grok | -32003 → `rate_limited`; for -32603, the final
`retry_state.error_type` |
| ACP | -32000 → `auth` (no `credential`); opencode by its words |

- Values a runtime declares but no run produced stay unmapped and are
documented.
- An OpenAI 429 whose code names a quota or a balance is `quota` /
`billing`; only a bare 429 is `rate_limited`.

**Fixed misclassifications (each now covered by a test)**
- claude: "Credit balance is too low" was `unknown`, now `billing`. An
oversized context was `unknown`, now `input_too_large`.
- codex: `serverOverloaded` was `unknown`, now `overloaded`.
`contextWindowExceeded` was `unknown`, now `input_too_large`.

**Docs**
- runtime-matrix: the mapping rules, the oar column of each table, the
known ambiguities, the vendor tests.
- conversation.md: `failureText` with `credential`, and `failureAdvice`.
- README; the claude, grok, cursor and kimi pages (kimi now links
MoonshotAI/kimi-code#1865); roadmap.

## Behavior changes worth a release note
- `FailureClass` has four new members: a host's exhaustive `switch` over
it stops compiling until it handles them.
- A 429 that names no quota or balance is now `rate_limited`; it was
`quota`.
- `failureText("auth", name)` without a credential now reads "could not
authenticate". It used to read "is not signed in", which was wrong for a
refused API key (the Raft complaint in #227).
- Some opens now reject with `RuntimeFailureError` (still an `Error`,
with the same message; its `reason` reads the message and the agent's
error is its `cause`, both redacted like the message when the session
carries credential-bearing `mcpServers`) where they rejected with the
raw `RequestError` or a plain `Error`:
  - an ACP agent that requires auth;
  - a -32602 model answer;
  - cursor's refused key;
  - a pi model oar doesn't find.
- A grok -32603 reason now includes its `data` text (the provider's
answer), not only "Internal error".

## Tests
- Unit tests for every mapping, built on the observed facts:
`tests/failure-mapping.test.ts` and `tests/failure-class.test.ts`
(shared rules, `failureAdvice`).
- A claude projection test for the wiring, and updated display-text
tests.
- Vendor tests, one per mapped cell:
- `sea-trial/vendor/failure-classes.vendor.test.ts` runs in CI against
the real binaries (claude 10 cells, codex 13, pi 11).
- `sea-trial/vendor/failure-classes-acp.vendor.test.ts` runs locally
like the other ACP vendor tests: grok 5, kimi 3, opencode 4, antigravity
3. It also pins kimi's and antigravity's completed-looking failures.
- Two existing vendor snapshots gained `status: 400`.
- `pnpm run check` is green (1127 tests, mock 19/19). After the rebase
onto main (#232, #233), the claude/codex/pi vendor suites pass locally,
and so do the four ACP suites.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant