fix(cli): handle flash model errors gracefully (#12667)

This commit is contained in:
Adam Weidman
2025-11-06 17:13:38 -05:00
committed by GitHub
parent 98055d0989
commit 1e42fdf6c2
4 changed files with 81 additions and 27 deletions
+4 -3
View File
@@ -73,14 +73,15 @@ describe('handleFallback', () => {
expect(mockConfig.setFallbackMode).not.toHaveBeenCalled();
});
it('should return null if the failed model is already the fallback model', async () => {
it('should still consult the handler if the failed model is the fallback model', async () => {
mockHandler.mockResolvedValue('stop');
const result = await handleFallback(
mockConfig,
FALLBACK_MODEL, // Failed model is Flash
AUTH_OAUTH,
);
expect(result).toBeNull();
expect(mockHandler).not.toHaveBeenCalled();
expect(result).toBe(false);
expect(mockHandler).toHaveBeenCalled();
});
it('should return null if no fallbackHandler is injected in config', async () => {
-2
View File
@@ -21,8 +21,6 @@ export async function handleFallback(
const fallbackModel = DEFAULT_GEMINI_FLASH_MODEL;
if (failedModel === fallbackModel) return null;
// Consult UI Handler for Intent
const fallbackModelHandler = config.fallbackModelHandler;
if (typeof fallbackModelHandler !== 'function') return null;