From 7f20425c98d5adb5531e6c33ed92975b71b34c90 Mon Sep 17 00:00:00 2001
From: Allen Hutchison <adh@google.com>
Date: Mon, 2 Jun 2025 13:55:54 -0700
Subject: feat(cli): add pro model availability check and fallback to flash
 (#608)

---
 packages/cli/src/gemini.tsx | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

(limited to 'packages/cli/src/gemini.tsx')

diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx
index 07551813..f8cc77b6 100644
--- a/packages/cli/src/gemini.tsx
+++ b/packages/cli/src/gemini.tsx
@@ -50,11 +50,19 @@ async function main() {
     console.warn(
       'GEMINI_CODE_SANDBOX_IMAGE is deprecated. Use GEMINI_SANDBOX_IMAGE_NAME instead.',
     );
-    process.env.GEMINI_SANDBOX_IMAGE = process.env.GEMINI_CODE_SANDBOX_IMAGE;
+    process.env.GEMINI_SANDBOX_IMAGE_NAME =
+      process.env.GEMINI_CODE_SANDBOX_IMAGE; // Corrected to GEMINI_SANDBOX_IMAGE_NAME
   }
 
   const settings = loadSettings(process.cwd());
-  const config = await loadCliConfig(settings.merged);
+  const { config, modelWasSwitched, originalModelBeforeSwitch, finalModel } =
+    await loadCliConfig(settings.merged);
+
+  if (modelWasSwitched && originalModelBeforeSwitch) {
+    console.log(
+      `[INFO] Your configured model (${originalModelBeforeSwitch}) was temporarily unavailable. Switched to ${finalModel} for this session.`,
+    );
+  }
 
   if (settings.merged.theme) {
     if (!themeManager.setActiveTheme(settings.merged.theme)) {
@@ -128,8 +136,10 @@ async function main() {
     ...settings.merged,
     coreTools: nonInteractiveTools,
   };
-  const nonInteractiveConfig = await loadCliConfig(nonInteractiveSettings);
-  await runNonInteractive(nonInteractiveConfig, input);
+  const nonInteractiveConfigResult = await loadCliConfig(
+    nonInteractiveSettings,
+  ); // Ensure config is reloaded with non-interactive tools
+  await runNonInteractive(nonInteractiveConfigResult.config, input);
 }
 
 // --- Global Unhandled Rejection Handler ---
-- 
cgit v1.2.3

