Repository navigation
fix(core): enable autonomous plan execution in non-interactive mode - #29539
Conversation
Ensure Plan Mode prompts do not mandate synchronous user consultation or block execution turns when running in non-interactive/headless mode. Guards Step 2 consultation, informal agreement exit requirements, and ask_user references with options.interactive to allow autonomous plan drafting and execution. Bug: b/561554615
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 enables autonomous operation for the agent in non-interactive (headless) environments by modifying the Plan Mode prompt workflow. Previously, strict consultation and user-agreement directives prevented headless agents from proceeding with tasks. The changes introduce conditional logic to bypass these interactive-only steps, allowing the agent to synthesize strategies and finalize plans autonomously when running in non-interactive mode. 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
|
|
📊 PR Size: size/L
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for a non-interactive plan mode workflow in the Gemini CLI core prompts. Specifically, it updates the planning workflow rendering in snippets.ts to conditionally display different instructions for Step 2 (Consult vs. Determine Strategy) and Step 4 (Review & Approval) depending on whether the session is interactive. It also refines Rule 3 (Efficiency) to exclude user-interaction directives in non-interactive mode. To support these changes, a new test file planModeNonInteractive.test.ts has been added to validate both interactive and non-interactive prompt generation. I have no feedback to provide as there are no review comments to assess.
|
/Gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for a non-interactive workflow in Plan Mode. It updates renderPlanningWorkflow in packages/core/src/prompts/snippets.ts to dynamically adjust the prompt sections (such as 'Consult' vs 'Determine Strategy' and 'Review & Approval') and rules based on whether the interactive option is enabled. Additionally, a comprehensive suite of unit tests has been added in packages/core/src/prompts/planModeNonInteractive.test.ts to verify both interactive and non-interactive prompt generation behaviors. There are no review comments, and I have no feedback to provide.
🚨 Action Required: Eval Regressions DetectedModel: The following trustworthy evaluations passed on
The check passed or was cleared for 69 other trustworthy evaluations. 🛠️ Troubleshooting & Fix Instructions1. Ask Gemini CLI to fix it (Recommended)Copy and paste this prompt to the agent: 2. Reproduce LocallyRun the following command to see the failure trajectory: GEMINI_MODEL=gemini-3-flash-preview npm run test:all_evals -- evals/automated-tool-use.eval.ts --testNamePattern="should use automated tools (prettier --write) to fix formatting issues"3. Manual FixSee the Fixing Guide for detailed troubleshooting steps. This PR modifies files that affect the model's behavior (prompts, tools, or instructions).
This is an automated guidance message triggered by steering logic signatures. |
Verify that the agent autonomously drafts an implementation plan and invokes exit_plan_mode without waiting for user agreement when running in non-interactive/headless mode.
🛑 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. |
Summary
Guards synchronous user consultation and agreement waiting directives in Plan Mode prompts with
options.interactive. In non-interactive/headless environments (interactive: false), Plan Mode now instructs the agent to synthesize strategy and proceed directly to plan drafting and execution without halting to wait for user confirmation.Details
In PR #24423, strict consultation requirements were added to Plan Mode prompts, including directives such as
STOP and wait, explicit prohibitions against drafting plans in the initial strategy turn, and mandates to reach informal agreement before callingexit_plan_mode. While appropriate for interactive CLI sessions, these instructions caused headless agent runs (e.g.gemini -p "..." -y) to output an alignment message with 0 tool calls. In non-interactive mode, generating a response with 0 tool calls triggers immediate session termination innonInteractiveCli, leaving the task unexecuted. Furthermore, the prompt instructed the agent to clarify viaask_user, a tool that is excluded and blocked by policy in headless mode.Changes in this PR:
renderPlanningWorkflowinpackages/core/src/prompts/snippets.ts:Consult): In interactive mode, retains the full consultation workflow and wait directives. In non-interactive mode, replaces this withDetermine Strategy, instructing the model to synthesize findings and proceed directly to Step 3 (Draft) autonomously without halting.Review & Approval): In interactive mode, retains the informal agreement requirement. In non-interactive mode, instructs the model to callexit_plan_modeto finalize the plan and begin implementation.Efficiency): Only includes instructions to clarify viaask_userwhenoptions.interactiveistrue.Draft): Preserves existing conditional rendering where humanAlignment Checkis only included whenoptions.interactiveistrue.packages/core/src/prompts/planModeNonInteractive.test.tsverifying prompt generation under interactive and non-interactive configurations for bothrenderPlanningWorkflowandPromptProvider.getCoreSystemPrompt.Related Issues
Fixes #28913
How to Validate
npm test -w @google/gemini-cli-core -- src/prompts/planModeNonInteractive.test.tsnpm test -w @google/gemini-cli-core -- src/prompts/npm test -w @google/gemini-cli-core -- src/core/prompts.test.tsnpm test -w @google/gemini-cli -- src/nonInteractiveCli.test.tsnpm run lint && npm run typecheckPre-Merge Checklist