Skip to content

Conversation

@CompilingChaos
Copy link

Summary

This PR introduces Steering Mode (activated via Ctrl+O), a "Human-in-the-loop" feature that allows users to provide asynchronous corrections or guidance to the agent while it is actively processing a task or streaming a response. This addresses the need for "mid-flight" course corrections without the heavy-handed approach of Ctrl+C.

Details

  • Asynchronous Injection & Persistence: When the agent is busy (e.g., executing tools or responding), submitting a prompt in Steering Mode injects a highly structured **STEERING CORRECTION** block. This correction now persists through all continuation turns (tool responses) within a single task, ensuring the agent adheres to the correction even during complex multi-step operations.
  • UI/Model Separation: Implemented a displayText mechanism for history items. The UI renders a clean, user-friendly version of the steering message, while the model receives the full templated string containing internal instructions.
  • Idle Steering: If the agent is idle, Steering Mode behaves like a normal prompt but automatically applies the steering template to ensure the model prioritizes the new guidance.
  • Core System Instruction: Added a specific "Respect Steering" mandate to the system prompt, explicitly instructing the model to prioritize these blocks over its original plans.
  • UI Enhancements: Added a specific placeholder (STEERING MODE: Inject correction...) and toggle state to clearly distinguish between standard input and steering input.

Architecture

  • History Extensions: Added displayText to HistoryItemBase to decouple UI rendering from model input.
  • Persistence Logic: Enhanced useGeminiStream with pendingSteeringMessageRef and steeringInjectedInCurrentTurnRef to manage correction injection across the tool loop.
  • System Prompts: Updated packages/core/src/core/prompts.ts with the "Respect Steering" rule and updated corresponding test snapshots.
  • Command Integration: Added TOGGLE_STEERING_MODE to Command enum and defaultKeyBindings.

Related Issues

Closes #17197

How to Validate

  1. Initiate Task: Run the following command:
    "write five python scripts showcasing important python features, test and write each one on its own."
    
  2. Steer Mid-Flight: While the agent is working (executing tools or writing), press Ctrl+O and enter:
    "Actually, make it only three python scripts."
    
  3. Verify Result: The agent should immediately pivot and complete the task with only three scripts instead of five.

Pre-Merge Checklist

  • Updated relevant documentation and README (Key bindings added to keyBindings.ts)
  • Added/updated tests (Verified useGeminiStream.test.tsx and prompt snapshots)
  • Noted breaking changes (None)
  • Validated on required platforms/methods:
    • MacOS
    • Windows
      • npm run
      • npx
    • Linux

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @CompilingChaos, 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 introduces a significant new feature called "Steering Mode," enabling users to provide real-time, asynchronous guidance and corrections to the agent without interrupting its ongoing tasks. This enhances user control by allowing mid-flight adjustments to the agent's behavior and plans, ensuring it stays aligned with user intent even during complex operations.

Highlights

  • Steering Mode Introduction: A new "Human-in-the-loop" feature activated by Ctrl+O allowing users to provide real-time corrections to the agent while it is actively processing a task.
  • Persistent Corrections: Steering messages are asynchronously injected and persist through continuation turns (e.g., tool responses), ensuring the agent adheres to the correction during complex multi-step operations.
  • UI/Model Decoupling: Implemented a displayText mechanism for history items, allowing the UI to render a clean, user-friendly version of the steering message while the model receives the full templated string containing internal instructions.
  • System Prompt Update: The core system prompt now includes an explicit instruction for the model to prioritize and respect **STEERING CORRECTION** blocks over its original plans.
  • UI Enhancements: The input placeholder dynamically changes to "STEERING MODE: Inject correction..." when active, providing clear visual feedback to the user.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 the 'Steering Mode' feature, designed to provide mid-flight corrections to the agent. While the implementation is well-structured, particularly the separation between the UI display text and the model's input via the displayText property, and the logic for persisting steering corrections across tool calls, a critical security vulnerability has been identified. The 'Respect Steering' mandate in the system prompt prioritizes content marked with the easily spoofable string (**STEERING CORRECTION**), making it vulnerable to Indirect Prompt Injection when the agent processes untrusted files or codebase content. This could enable an attacker to gain control over the agent's actions, potentially leading to Remote Code Execution. Additionally, there is a high-severity issue concerning how steering messages are handled for the user's input history and the message queue, which could lead to a confusing user experience.

- Update system prompt to instruct model to ignore steering tags in file content.

- Inject active steering instruction at the end of user turns if steering is detected.

- Add integration test for steering hijack mitigation.
@CompilingChaos
Copy link
Author

/gemini review

Copy link
Contributor

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

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 a well-designed "Steering Mode" feature, allowing for mid-flight corrections to the agent. The implementation is robust, covering persistence across tool calls and separating UI display from model input. The inclusion of an integration test to prevent prompt injection from file contents is a commendable security measure. I've identified one high-severity logical issue in the core hook where a parameter is being used incorrectly, which could lead to future bugs.

@CompilingChaos
Copy link
Author

/gemini review

Copy link
Contributor

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

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 a well-designed Steering Mode feature, enabling mid-flight course corrections for the agent. The implementation thoughtfully addresses asynchronous injection, persistence across turns, and UI/Model separation. The changes are comprehensive and align with the feature's goals.

@CompilingChaos CompilingChaos marked this pull request as ready for review January 24, 2026 20:00
@CompilingChaos CompilingChaos requested a review from a team as a code owner January 24, 2026 20:00
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Jan 27, 2026

Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request.

To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues.

If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding!

@gemini-cli gemini-cli bot closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /inject command for asynchronous mid-stream agent steering

1 participant