Skip to content

fix(core): stop Plan Mode from waiting on user feedback in non-interactive sessions - #29063

Open
chelsealong wants to merge 2 commits into
google-gemini:mainfrom
chelsealong:fix/plan-mode-non-interactive-wait-28913
Open

fix(core): stop Plan Mode from waiting on user feedback in non-interactive sessions#29063
chelsealong wants to merge 2 commits into
google-gemini:mainfrom
chelsealong:fix/plan-mode-non-interactive-wait-28913

Conversation

@chelsealong

Copy link
Copy Markdown

Summary

Fixes #28913. In non-interactive mode (e.g. gemini -p "..." -y), Plan Mode's workflow instructions told the agent to stop and wait for a user turn that will never arrive, causing non-interactive Plan Mode runs to hang — exactly the behavior reported in #28913 and its predecessor #26004.

This runtime has two parallel, structurally-independent prompt template files, selected at runtime by supportsModernFeatures(desiredModel) in packages/core/src/prompts/promptProvider.ts:

  • packages/core/src/prompts/snippets.ts ("modern" — used for Gemini 3 / custom models)
  • packages/core/src/prompts/snippets.legacy.ts ("legacy" — used for all other models, including the default gemini-2.5-pro)

Both files had their own copy of the same bug in renderPlanningWorkflow, and both are fixed here.

Details

Modern path (snippets.ts)

  • Extracted the Step 2 "Consult" instructions into a new renderPlanningConsultStep(interactive: boolean) helper, mirroring the existing pattern used elsewhere in this file (e.g. mandateContinueWork, workflowVerifyStandardsSuffix) for branching prompt text on options.interactive.
    • Interactive sessions keep the exact original text (STOP-and-wait, ask_user consultation, etc.) — verified byte-for-byte via existing prompt snapshot tests, which still pass unmodified.
    • Non-interactive sessions now get: "No user is available to consult in this non-interactive session, so briefly note your proposed strategy, then proceed directly to Step 3 (Draft) without waiting for feedback."
  • Also guarded the Step 4 "Review & Approval" sentence that unconditionally referenced reaching "an informal agreement with the user in the chat" — same bug, same fix shape, since that step follows directly from Step 2/3.

Legacy path (snippets.legacy.ts)

An initial version of this PR only patched the modern file. A review caught that snippets.legacy.ts has its own renderPlanningWorkflow with the identical defect, reachable by any session resolving to a non-"modern" model (e.g. OAuth users without confirmed preview-model access, or --model gemini-2.5-pro/gemini-2.5-flash) — a real, non-theoretical subset of non-interactive users that the original fix left broken.

  • Added interactive: boolean to PlanningWorkflowOptions in snippets.legacy.ts (it was previously omitted from the type even though the caller already passed it — see promptProvider.ts:202-220, interactive: interactiveMode).
  • Guarded the "IMPORTANT: ... Wait for user input before proceeding to the next phase." line in renderPlanningWorkflow: non-interactive sessions now get "No user is available to consult in this non-interactive session, so proceed directly to the next phase using your best judgement instead of waiting for input."
  • Guarded the Phase 1 ask_user clarifying-questions guidance the same way: non-interactive sessions are told to make reasonable assumptions instead of asking, since no user is available.

No changes to policy engine, tool availability, or non-prompt logic — this is a prompt-text fix only, touching only the two snippet files and their shared test file.

Testing

Added tests to packages/core/src/core/prompts.test.ts, covering both prompt paths:

  • should not tell the agent to wait for user feedback in non-interactive PLAN mode (modern)
  • should tell the agent to wait for user feedback in interactive PLAN mode (modern)
  • should not tell the agent to wait for user input in non-interactive PLAN mode (legacy prompt)
  • should tell the agent to wait for user input in interactive PLAN mode (legacy prompt)

Verified the new legacy-path test fails without the legacy fix:

$ git checkout HEAD~1 -- packages/core/src/prompts/snippets.legacy.ts
$ npx vitest run src/core/prompts.test.ts -t "legacy prompt"
 FAIL  src/core/prompts.test.ts > ... > should not tell the agent to wait for user input in non-interactive PLAN mode (legacy prompt)
 AssertionError: expected '...Wait for user input before proceeding to the next phase...' not to contain 'Wait for user input before proceeding to the next phase'
 Test Files  1 failed (1)
      Tests  1 failed | 2 passed | 71 skipped (74)
$ git checkout HEAD -- packages/core/src/prompts/snippets.legacy.ts

(The modern-path revert-and-fail was verified identically in the prior review pass: reverting snippets.ts alone causes the modern non-interactive test to fail with AssertionError: expected '...STOP and wait...' not to contain 'STOP and wait'.)

With the fix applied:

$ npx vitest run src/core/prompts.test.ts
 Test Files  1 passed (1)
      Tests  74 passed (74)
$ npx vitest run src/prompts src/core/prompts.test.ts   # full prompts + provider suite
 Test Files  6 passed (6)
      Tests  135 passed (135)

Also ran:

$ npx eslint packages/core/src/prompts/snippets.legacy.ts packages/core/src/core/prompts.test.ts   # clean
$ npx tsc -p packages/core/tsconfig.json --noEmit                                                  # clean

AI assistance disclosure

This change (analysis, implementation, and tests) was prepared with AI assistance (Claude Code / Anthropic).

…ctive sessions

The Consult step of renderPlanningWorkflow told the agent to "STOP and
wait" for informal user agreement before drafting a plan, and to never
proceed to Draft/Review in the same turn without that feedback. This
instruction was not guarded by options.interactive, so non-interactive
runs (e.g. `gemini -p "..." -y`) could emit a text-only confirmation
request and terminate instead of completing the plan autonomously.

Guard the wait-for-feedback directives with options.interactive,
mirroring the pattern already used elsewhere in this file, so
non-interactive sessions proceed directly to drafting instead of
waiting for a user turn that will never come.

Fixes google-gemini#28913
The interactive-wait guard added for the modern prompt template
(snippets.ts) was missing from the legacy template used for
non-modern models (snippets.legacy.ts), which is selected via
supportsModernFeatures() for models like gemini-2.5-pro. Its
renderPlanningWorkflow unconditionally told the agent to wait for
user input between phases, reproducing the original hang for
non-interactive sessions on that model path.
@chelsealong
chelsealong requested review from a team as code owners August 25, 2026 02:00
@github-actions github-actions Bot added the size/m A medium sized PR label Aug 25, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 86
  • Additions: +76
  • Deletions: -10
  • Files changed: 3

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a long-standing issue where Plan Mode would hang in non-interactive environments by incorrectly instructing the agent to wait for user feedback. By introducing conditional logic into the prompt templates, the agent is now correctly instructed to proceed using its best judgment when no user is available to consult. This change ensures consistent, non-blocking behavior across both modern and legacy prompt architectures.

Highlights

  • Non-interactive Plan Mode Fix: Updated prompt templates to prevent the agent from waiting for user input in non-interactive sessions, resolving issues where Plan Mode would hang.
  • Dual-path Prompt Support: Applied fixes to both modern (snippets.ts) and legacy (snippets.legacy.ts) prompt templates to ensure consistent behavior across all model types.
  • Enhanced Testing: Added comprehensive test cases to verify that both modern and legacy prompt paths correctly handle interactive vs. non-interactive modes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

Copy link
Copy Markdown

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for non-interactive sessions within the planning workflow prompts (both standard and legacy). It updates the prompts to conditionally instruct the agent to proceed directly using its best judgment and make reasonable assumptions when running in a non-interactive mode, rather than waiting for user feedback or asking clarifying questions. Corresponding unit tests have been added to verify this behavior under both interactive and non-interactive configurations. There are no review comments, and I have no additional feedback to provide.

@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/non-interactive Issues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation priority/p1 Important and should be addressed in the near term. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plan Mode still halts YOLO / non-interactive runs while waiting for user agreement

1 participant