mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix: remove 400 errors from model history
This commit is contained in:
@@ -1279,13 +1279,10 @@ describe('GeminiChat', () => {
|
|||||||
expect(mockLogContentRetry).toHaveBeenCalledTimes(1);
|
expect(mockLogContentRetry).toHaveBeenCalledTimes(1);
|
||||||
expect(mockLogContentRetryFailure).toHaveBeenCalledTimes(1);
|
expect(mockLogContentRetryFailure).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
// History should still contain the user message.
|
// History should NOT contain the failed user message,
|
||||||
|
// to prevent invalid content from breaking subsequent requests.
|
||||||
const history = chat.getHistory();
|
const history = chat.getHistory();
|
||||||
expect(history.length).toBe(1);
|
expect(history.length).toBe(0);
|
||||||
expect(history[0]).toEqual({
|
|
||||||
role: 'user',
|
|
||||||
parts: [{ text: 'test' }],
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('API error retry behavior', () => {
|
describe('API error retry behavior', () => {
|
||||||
|
|||||||
@@ -380,6 +380,8 @@ export class GeminiChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isConnectionPhase) {
|
if (isConnectionPhase) {
|
||||||
|
// Remove failed user content so it doesn't break subsequent requests
|
||||||
|
this.history.pop();
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
lastError = error;
|
lastError = error;
|
||||||
@@ -429,6 +431,8 @@ export class GeminiChat {
|
|||||||
new ContentRetryFailureEvent(maxAttempts, lastError.type, model),
|
new ContentRetryFailureEvent(maxAttempts, lastError.type, model),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// Remove failed user content so it doesn't break subsequent requests
|
||||||
|
this.history.pop();
|
||||||
throw lastError;
|
throw lastError;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user