Skip to content

fix(core): enable autonomous plan execution in non-interactive mode - #29539

Merged
DavidAPierce merged 4 commits into
google-gemini:mainfrom
urielefrenvirtusa:b_561554615
Sep 29, 2026
Merged

DavidAPierce merged 4 commits into
google-gemini:mainfrom
urielefrenvirtusa:b_561554615

Conversation

@urielefrenvirtusa

Copy link
Copy Markdown
Contributor

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 calling exit_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 in nonInteractiveCli, leaving the task unexecuted. Furthermore, the prompt instructed the agent to clarify via ask_user, a tool that is excluded and blocked by policy in headless mode.

Changes in this PR:

  • Updated renderPlanningWorkflow in packages/core/src/prompts/snippets.ts:
    • Step 2 (Consult): In interactive mode, retains the full consultation workflow and wait directives. In non-interactive mode, replaces this with Determine Strategy, instructing the model to synthesize findings and proceed directly to Step 3 (Draft) autonomously without halting.
    • Step 4 (Review & Approval): In interactive mode, retains the informal agreement requirement. In non-interactive mode, instructs the model to call exit_plan_mode to finalize the plan and begin implementation.
    • Rule 3 (Efficiency): Only includes instructions to clarify via ask_user when options.interactive is true.
    • Step 3 (Draft): Preserves existing conditional rendering where human Alignment Check is only included when options.interactive is true.
  • Added comprehensive unit tests in packages/core/src/prompts/planModeNonInteractive.test.ts verifying prompt generation under interactive and non-interactive configurations for both renderPlanningWorkflow and PromptProvider.getCoreSystemPrompt.

Related Issues

Fixes #28913

How to Validate

  1. Run the targeted Plan Mode prompt test suite:
    npm test -w @google/gemini-cli-core -- src/prompts/planModeNonInteractive.test.ts
  2. Run all prompt test suites in core:
    npm test -w @google/gemini-cli-core -- src/prompts/
  3. Run core snapshot tests to confirm zero regressions in interactive mode:
    npm test -w @google/gemini-cli-core -- src/core/prompts.test.ts
  4. Verify non-interactive CLI tests:
    npm test -w @google/gemini-cli -- src/nonInteractiveCli.test.ts
  5. Run lint and typecheck:
    npm run lint && npm run typecheck

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

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
@urielefrenvirtusa
urielefrenvirtusa requested a review from a team as a code owner September 28, 2026 17:05
@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 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

  • Autonomous Plan Execution: Enabled autonomous plan execution in non-interactive mode by removing blocking user consultation and agreement requirements.
  • Prompt Workflow Refactoring: Updated renderPlanningWorkflow to conditionally render steps based on the interactive flag, ensuring headless agents proceed directly to drafting and implementation.
  • Testing: Added comprehensive unit tests in planModeNonInteractive.test.ts to verify prompt generation and agent behavior in both interactive and non-interactive configurations.
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 github-actions Bot added the size/m A medium sized PR label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 266
  • Additions: +257
  • Deletions: -9
  • Files changed: 3

@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 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-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 Sep 28, 2026
@urielefrenvirtusa

Copy link
Copy Markdown
Contributor Author

/Gemini review

@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 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.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🚨 Action Required: Eval Regressions Detected

Model: gemini-3-flash-preview

The following trustworthy evaluations passed on main and in recent Nightly runs, but failed in this PR. These regressions must be addressed before merging.

Test Name Nightly PR Result Status
should use automated tools (prettier --write) to fix formatting issues 100% 25% ❌ Regression

The check passed or was cleared for 69 other trustworthy evaluations.

🛠️ Troubleshooting & Fix Instructions

1. Ask Gemini CLI to fix it (Recommended)

Copy and paste this prompt to the agent:

The eval "should use automated tools (prettier --write) to fix formatting issues" in evals/automated-tool-use.eval.ts is failing. Investigate and fix it using the behavioral-evals skill.

2. Reproduce Locally

Run 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 Fix

See the Fixing Guide for detailed troubleshooting steps.

### 🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

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.
@DavidAPierce
DavidAPierce added this pull request to the merge queue Sep 29, 2026
@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.

Merged via the queue into google-gemini:main with commit f5dc904 Sep 29, 2026
9 of 10 checks passed
@urielefrenvirtusa
urielefrenvirtusa deleted the b_561554615 branch September 29, 2026 16:22

This branch is waiting to be deployed

1 waiting deployment
eval-gate — a58d3989 Waiting Sep 29, 2026 by DavidAPierce via Evaluate Steering & Regressions #2105
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/l A large sized PR 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

2 participants