mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 23:21:27 -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(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();
|
||||
expect(history.length).toBe(1);
|
||||
expect(history[0]).toEqual({
|
||||
role: 'user',
|
||||
parts: [{ text: 'test' }],
|
||||
});
|
||||
expect(history.length).toBe(0);
|
||||
});
|
||||
|
||||
describe('API error retry behavior', () => {
|
||||
|
||||
@@ -380,6 +380,8 @@ export class GeminiChat {
|
||||
}
|
||||
|
||||
if (isConnectionPhase) {
|
||||
// Remove failed user content so it doesn't break subsequent requests
|
||||
this.history.pop();
|
||||
throw error;
|
||||
}
|
||||
lastError = error;
|
||||
@@ -429,6 +431,8 @@ export class GeminiChat {
|
||||
new ContentRetryFailureEvent(maxAttempts, lastError.type, model),
|
||||
);
|
||||
}
|
||||
// Remove failed user content so it doesn't break subsequent requests
|
||||
this.history.pop();
|
||||
throw lastError;
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user