fix(core): stop Plan Mode from waiting on user feedback in non-interactive sessions - #29063
fix(core): stop Plan Mode from waiting on user feedback in non-interactive sessions#29063chelsealong wants to merge 2 commits into
Conversation
…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.
|
📊 PR Size: size/M
|
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
🛑 Action Required: Evaluation ApprovalSteering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged. Maintainers:
Once approved, the evaluation results will be posted here automatically. |
There was a problem hiding this comment.
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.
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)inpackages/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 defaultgemini-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)renderPlanningConsultStep(interactive: boolean)helper, mirroring the existing pattern used elsewhere in this file (e.g.mandateContinueWork,workflowVerifyStandardsSuffix) for branching prompt text onoptions.interactive.ask_userconsultation, etc.) — verified byte-for-byte via existing prompt snapshot tests, which still pass unmodified.Legacy path (
snippets.legacy.ts)An initial version of this PR only patched the modern file. A review caught that
snippets.legacy.tshas its ownrenderPlanningWorkflowwith 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.interactive: booleantoPlanningWorkflowOptionsinsnippets.legacy.ts(it was previously omitted from the type even though the caller already passed it — seepromptProvider.ts:202-220,interactive: interactiveMode).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."ask_userclarifying-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:
(The modern-path revert-and-fail was verified identically in the prior review pass: reverting
snippets.tsalone causes the modern non-interactive test to fail withAssertionError: expected '...STOP and wait...' not to contain 'STOP and wait'.)With the fix applied:
Also ran:
AI assistance disclosure
This change (analysis, implementation, and tests) was prepared with AI assistance (Claude Code / Anthropic).