ADR 0007doc/{zh,en}/adr/0007-error-data.md

ADR 0007: Typed Error Data

Status: accepted, 2026-11-17 (P3; the owner asked for every proposal up to P50 to be finished).

Status: accepted, 2026-11-17 (P3; the owner asked for every proposal up to P50 to be finished).

Context

plugin.Error carries a code, retryability, not_sent and a message. A caller that needs a number from the failure has to parse the message, which section 12 of AGENTS.md forbids. The case that exists today: a rate-limited model answers 429 with Retry-After: 120. The openai plugin honors waits up to 60 s and ignored longer ones, so it retried on its own short backoff into the same limit, spending its attempts before the Agent could fall back to the next model. The LLM layer (section 10) already specifies the fix: a wait over 60 s fails at once with retry_after_ms in the error data.

Decision

  1. Contract. plugin.Error gains Data map[string]any (JSON data, omitted when empty). It holds facts about the failure, never instructions; consumers read the keys they know and ignore the rest. Keys are snake_case and stable like codes. The first key is retry_after_ms (integer): the provider's wait before the same request may succeed.
  2. Process plugins. rpc.ToWire already encodes the whole plugin.Error in the JSON-RPC error data, so data crosses the process boundary in both directions with no protocol change.
  3. openai. Wait hints are read from retry-after-ms, then Retry-After as seconds or an HTTP date. A wait up to 60 s is honored before the next attempt as today; a longer one ends the call at once with the retryable llm.rate_limited (or llm.server_error for 503) and retry_after_ms in data.
  4. Agent. Unchanged: a retryable error already moves to the next fallback model, so a long wait now switches models at once.

Consequences

  • ◆JSON stays compatible: old plugins send no data, old consumers ignore it.
  • ◆Later keys (context numbers of an overflow, usage of a failed call) are added with the consumer that needs them, listed in the LLM layer design; no generic schema registry.
  • ◆No Host branch reads data today; the Host logs errors by code as before.