Skip to content

fix: readable provider errors and overload backoff retry (#429) - #432

Merged
ProfSynapse merged 1 commit into
mainfrom
fix/429-google-error-visibility
Oct 30, 2026
Merged

ProfSynapse merged 1 commit into
mainfrom
fix/429-google-error-visibility

Conversation

@ProfSynapse

Copy link
Copy Markdown
Owner

Closes #429.

What was wrong

On iOS with Gemini, a failed reply showed a solid red rectangle with no text. The chat error toast set background: var(--background-modifier-error) and color: var(--text-error), and Obsidian defines both as var(--color-red). The provider's real message was there, red on red, and it removed itself after 5 seconds. The failures underneath were Google free-tier 503 (overloaded) and 429 (quota) responses. The request path itself is fine: six live calls to gemini-3.8-flash with medium thinking all succeeded on a paid key.

Changes

Readable errors

  • Error backgrounds are tinted (rgba(var(--background-modifier-error-rgb), 0.1)) in .chat-error, .nexus-error, .nexus-instruction-error and .dimension-warning-container.
  • The chat error now stays until dismissed (× button) or until the next turn starts. Only the latest error is shown, and its text can be selected.
  • Provider failures are worded for people: "Google AI is overloaded right now. Wait a moment and try again, or switch to a different model. (HTTP 503)". This covers HTTP errors (ProviderHttpError), in-stream error frames (Anthropic overloaded_error, google.rpc.Status, OpenAI codes) and the non-streaming handleError path.
  • The raw provider text is kept on technicalMessage for logs.
  • Provider display names moved to services/llm/providers/providerDisplayNames.ts, so the adapter layer can use them without importing UI code.

Overload backoff retry

  • streamWithOverloadRetry wraps every adapter stream: the main turn, the tool continuation and the recursive continuation.
  • It triggers on HTTP 503/529, or on an overload frame that arrives after HTTP 200.
  • Backoff is exponential with jitter (about 1s, 2s, 4s, 8s; 4 retries). It honours retry-after, retry-after-ms and Google RetryInfo. If the provider asks for more than 20s, the error is shown instead.
  • Retrying only happens before the first output chunk, so nothing the user has seen is replayed. A 429 is never retried.
  • While waiting, a new status-only provider.retrying runtime event shows "Google AI is overloaded. Retrying 2/4…" on the chat status line. It clears when output starts or the turn ends.
  • Google streaming now receives the abort signal, so Stop cancels the wait.

Regressions found and fixed along the way

  • LM Studio's draft-model fallback regex-matched err.message. Rewording would have broken it, so it now reads technicalMessage. A new status-coded fixture covers it.
  • Holding back non-output chunks during retry dropped usage on a failure that isn't retried (caught by EvalRunnerBudget). Held chunks are now flushed before rethrowing.

Verification

  • npm run build passes, including lint and the mobile Node-import reachability check.
  • Full Jest suite: 6862 passed, 0 failed.
  • check_stream_error_wiring.py: clean on all 14 streaming adapters.
  • Live: RUN_GOOGLE_REASONING_SMOKE=1 passes through the changed path. Google's real error body shape was confirmed with a live invalid-key call.
  • Mutation-checked: removing the retry at each of the three call sites, removing the MessageManager pass-through of the retry notice, or reverting LM Studio to err.message each fails its test.
  • Not checked: on a physical iPhone, or the status line's look in the running app.

🤖 Generated with Claude Code

An iOS user on Gemini saw a solid red box instead of an error. The chat
error toast painted --text-error on --background-modifier-error, which
Obsidian defines as the same red, and dismissed itself after 5 seconds.
Google's free tier was returning 503/429 underneath.

- Tint error backgrounds so the text is readable; the chat error now
  stays until dismissed or the next turn starts.
- Word provider failures for people ("Google AI is overloaded right
  now... (HTTP 503)") on HTTP errors, in-stream error frames and the
  non-streaming handleError path. The raw text stays on
  technicalMessage; LM Studio's draft fallback now matches on it.
- streamWithOverloadRetry wraps every adapter stream (turn, tool
  continuation, recursive continuation): exponential backoff with
  jitter on 503/529 or an overload frame, honouring Retry-After and
  Google RetryInfo, only until the first output chunk. Never retries 429.
- Show "<Provider> is overloaded. Retrying X/Y..." on the status line
  via a new provider.retrying runtime event.
- Pass the abort signal to Google streaming requests.

Closes #429

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ProfSynapse
ProfSynapse merged commit e4721ac into main Oct 30, 2026
1 check passed
@ProfSynapse
ProfSynapse deleted the fix/429-google-error-visibility branch October 30, 2026 15:31
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.

iOS native chat intermittently returns blank red error panel with Google AI

1 participant