fix: improve Cloud Code Assist 404 error with actionable model guidance (#384)

* 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.
This commit is contained in:
Flux Labs 2026-03-14 13:44:51 -05:00 committed by GitHub
parent 9d7323dda1
commit 1f0c57aadf

View file

@ -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"