Skip to content

Commit 57f8bfb

Browse files
committed
delegate.js: classify transient vs permanent Gemini errors instead of always suggesting resume
callGenerateContentOnce/callGenerateContent already tag network-layer failures with err.status (429/503 are the documented transient cases -- see client.js's own model-cascade, which already only retries on 429). Everything else -- a malformed request (400), auth/config problems (401/403, or no status at all e.g. "GEMINI_API_KEY is not set"), or "Gemini returned no candidates" from a safety/recitation block -- will reproduce identically on retry. The per-step failure message previously treated all of these the same way and always told the caller to resume, which is actively misleading for the non-transient cases. Added isTransientGeminiError() and branched the message accordingly.
1 parent 6038a34 commit 57f8bfb

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

connectors/gemini/delegate.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ import { DEFAULT_OWNER } from "../../config.js";
3434

3535
const HARD_MAX_STEPS = 20;
3636

37+
// 429 (rate limit) and 503 (overloaded/high demand) are the only cases
38+
// documented as transient -- see client.js's own model-fallback cascade,
39+
// which deliberately only retries a different model on a 429 for the same
40+
// reason. Everything else (400 malformed request, 401/403 auth, 404 unknown
41+
// model, or no err.status at all -- e.g. "GEMINI_API_KEY is not set" thrown
42+
// locally in client.js, or "Gemini returned no candidates" from a
43+
// safety/recitation block) is a config or request problem that will
44+
// reproduce identically on a resume, not something retrying fixes.
45+
function isTransientGeminiError(err) {
46+
return err?.status === 429 || err?.status === 503;
47+
}
48+
3749
// Minimal line-based diff (LCS backtrace) -- good enough for investigation
3850
// summaries, not a full unified-diff implementation. Capped so a huge file
3951
// pair can't blow up the O(n*m) table.

0 commit comments

Comments
 (0)