chore: only pop nonretryable errors

This commit is contained in:
Jack Wotherspoon
2026-01-20 09:08:34 -05:00
parent 53994b2ff0
commit 7a687ce858

View File

@@ -379,11 +379,6 @@ export class GeminiChat {
return; // Stop the generator
}
if (isConnectionPhase) {
// Remove failed user content so it doesn't break subsequent requests
this.history.pop();
throw error;
}
lastError = error;
const isContentError = error instanceof InvalidStreamError;
const isRetryable = isRetryableError(
@@ -391,6 +386,12 @@ export class GeminiChat {
this.config.getRetryFetchErrors(),
);
// For non-retryable connection errors, pop history and throw immediately
if (isConnectionPhase && !isRetryable) {
this.history.pop();
throw error;
}
if (
(isContentError && isGemini2Model(model)) ||
(isRetryable && !signal.aborted)