{"record":{"id":"11214f2c557eca70","repo":"google-gemini/gemini-cli","slug":"exiting-due-to-a-confirmation-prompt-requested-by","errorCode":null,"errorMessage":"Exiting due to a confirmation prompt requested by the command.","messagePattern":"Exiting due to a confirmation prompt requested by the command\\.","errorType":"exception","errorClass":"FatalInputError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/nonInteractiveCliCommands.ts","lineNumber":100,"sourceCode":"          name: commandToExecute.name,\n          args,\n        },\n      };\n\n      const result = await commandToExecute.action(commandContext, args);\n\n      if (result) {\n        switch (result.type) {\n          case 'submit_prompt':\n            return result.content;\n          case 'confirm_shell_commands':\n            // This result indicates a command attempted to confirm shell commands.\n            // However note that currently, ShellTool is excluded in non-interactive\n            // mode unless 'YOLO mode' is active, so confirmation actually won't\n            // occur because of YOLO mode.\n            // This ensures that if a command *does* request confirmation (e.g.\n            // in the future with more granular permissions), it's handled appropriately.\n            throw new FatalInputError(\n              'Exiting due to a confirmation prompt requested by the command.',\n            );\n          default:\n            throw new FatalInputError(\n              'Exiting due to command result that is not supported in non-interactive mode.',\n            );\n        }\n      }\n    }\n  }\n\n  return;\n};\n","sourceCodeStart":82,"sourceCodeEnd":114,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/nonInteractiveCliCommands.ts#L82-L114","documentation":"Thrown when a slash command run in non-interactive mode returns a result of type 'confirm_shell_commands'. It is a FatalInputError (exit code 42). Non-interactive mode has no UI to present a confirmation prompt, so any command that requests shell-command confirmation aborts. (Note: ShellTool is normally excluded in non-interactive mode unless YOLO is active, so this is largely defensive.)","triggerScenarios":"A built-in/custom slash command emits a confirm_shell_commands result during a `gemini -p` / non-interactive run, where no interactive prompt can be shown.","commonSituations":"Running a custom command that asks for shell confirmation in a pipeline/CI; a future granular-permissions command that requests confirmation without YOLO enabled.","solutions":["Enable YOLO mode (which bypasses shell confirmation) if it is safe to do so for that run.","Run the command in interactive mode where the confirmation prompt can be displayed.","Adjust the command/policy so it does not require confirmation in non-interactive contexts (add the command to the session shell allowlist or an allow policy)."],"exampleFix":"# before (aborts in non-interactive)\ngemini -p \"/my-cmd\"\n# after — allow without prompt, or run interactively\ngemini --yolo -p \"/my-cmd\"\n# or\ngemini   # then run /my-cmd interactively","handlingStrategy":"validation","validationCode":"function safeForNonInteractive(resultType: string): boolean {\n  return resultType === 'submit_prompt';\n}\n// before launching non-interactive, ensure the command does not return 'confirm_shell_commands'","typeGuard":"function isConfirmResult(r: { type: string }): boolean {\n  return r.type === 'confirm_shell_commands';\n}","tryCatchPattern":"try {\n  await runNonInteractive();\n} catch (e) {\n  if (e instanceof FatalInputError && /confirmation prompt/.test(e.message)) {\n    // exit code 42: enable YOLO or run interactively\n  }\n  throw e;\n}","preventionTips":["Do not run confirmation-requiring slash commands in pipelines unless YOLO is enabled.","Add commands you trust to the shell allowlist/allow policy so they skip confirmation.","Reserve interactive-only commands for interactive sessions."],"tags":["non-interactive","slash-command","confirmation","shell","permissions"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}