Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

Merge pull request #2041 from xpeng5278-web/fix/gemini-json-http-status

Land731d6b56ea7
diff --cc docs/spec/03-runtime/08-error-codes.md
index d99290a3b,f88132406..6f7ca857f
--- a/docs/spec/03-runtime/08-error-codes.md
+++ b/docs/spec/03-runtime/08-error-codes.md
@@@ -377,13 -377,15 +377,17 @@@ exceeds max length`, xAI `maximum promp
Bedrock `Input is too long for requested model`. `CONTEXT_TOO_LARGE` is never
replayed by either retry budget, and a delegate reports it as
`SUBAGENT_CONTEXT_OVERFLOW`. Explicit billing/account exhaustion codes and
-messages (including `insufficient_quota`, `credit_balance_exhausted`, and
-organization/project spend-limit codes) map to terminal `PROVIDER_ERROR` even
-when the HTTP status is 429. Throughput rate-limit wording, including
+messages (including `insufficient_quota`, `credit_balance_exhausted`,
+organization/project spend-limit codes, `insufficient credits`, and
+`requires more credits`) map to terminal `PROVIDER_ERROR` even when the HTTP
+status is 429, and HTTP 402 is terminal `PROVIDER_ERROR` even when the body
+omits those phrases. Throughput rate-limit wording, including
Bedrock's `Throttling error: Too many tokens, please wait before trying again.`,
- stays `PROVIDER_RATE_LIMITED`.
+ stays `PROVIDER_RATE_LIMITED`. An unprefixed JSON error body that carries an
+ HTTP status in `error.code` (Gemini's `@google/genai` `ApiError.message`) is
+ classified from that 400-599 code the same way as a `<status>:` message:
+ 400/422 stay terminal unless they report a context overflow, 404 is
+ `MODEL_NOT_CONFIGURED`, and 429 / 5xx stay retryable.
An exact `terminated` provider message and equivalent premature stream-close
messages map to `STREAM_FAILED`. A message is `TURN_ABORTED` only for a