From 1f0c57aadf091e40b2347a144bdaad9e685d2e89 Mon Sep 17 00:00:00 2001 From: Flux Labs Date: Sat, 14 Mar 2026 13:44:51 -0500 Subject: [PATCH] fix: improve Cloud Code Assist 404 error with actionable model guidance (#384) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(auto): prevent hang when dispatch chain breaks after slice tasks complete (#381) After the last task in a slice completes, dispatchNextUnit() can throw (e.g. template mismatch, branch error, or any unprotected operation). The error propagates to the pi event emitter which silently swallows async rejections, leaving auto-mode active but permanently stalled — no dispatch, no stop, no recovery. Three defensive layers added: 1. Try-catch around dispatchNextUnit in handleAgentEnd — catches errors, shows them to the user, and schedules a retry via the gap watchdog. 2. Dispatch gap watchdog (30s timer) — fires when auto-mode is active but no unit was dispatched after a unit completion. Re-derives state and retries. If retry fails, stops auto-mode with diagnostics. 3. Error boundary in the agent_end event handler — last-resort catch that pauses auto-mode if handleAgentEnd itself throws. Closes #381 * fix: improve Cloud Code Assist 404 error with actionable model guidance (#368) When a model like gemini-2.0-flash isn't available via Cloud Code Assist, the 404 error now names the model and suggests using the google provider with GOOGLE_API_KEY or switching to a supported model. --- packages/pi-ai/src/providers/google-gemini-cli.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/pi-ai/src/providers/google-gemini-cli.ts b/packages/pi-ai/src/providers/google-gemini-cli.ts index 67eccdbcc..c533fc7d1 100644 --- a/packages/pi-ai/src/providers/google-gemini-cli.ts +++ b/packages/pi-ai/src/providers/google-gemini-cli.ts @@ -446,6 +446,14 @@ export const streamGoogleGeminiCli: StreamFunction<"google-gemini-cli", GoogleGe } // Not retryable or max retries exceeded + if (response.status === 404) { + throw new Error( + `Cloud Code Assist API error (404): Model "${model.id}" was not found. ` + + `This model may not be available via Cloud Code Assist. ` + + `Try using the "google" provider with a GOOGLE_API_KEY instead, ` + + `or switch to a supported model (e.g., gemini-2.5-pro).`, + ); + } throw new Error(`Cloud Code Assist API error (${response.status}): ${extractErrorMessage(errorText)}`); } catch (error) { // Check for abort - fetch throws AbortError, our code throws "Request was aborted"