feat: experimental in-progress steering hints#18783
feat: experimental in-progress steering hints#18783LyalinDotCom wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello @LyalinDotCom, 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 an experimental feature that significantly enhances user interaction by allowing real-time 'steering hints' to be provided to the agent during active execution. This enables users to guide or correct the agent's behavior mid-process, making the interaction more dynamic and responsive. The implementation includes updates to input handling, prompt injection mechanisms, and a new lightweight model for generating immediate user acknowledgments. Highlights
Changelog
Activity
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 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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces an experimental feature for in-progress steering hints, allowing users to guide the agent during an active turn. The implementation is comprehensive, covering UI, state management, and core agent logic. However, I've identified a critical security vulnerability related to prompt injection. The user-provided hint text is not sanitized before being embedded into LLM prompts, which could allow a malicious user to manipulate the agent's behavior. My review includes a specific code suggestion to address this vulnerability by sanitizing the input.
| const trimmed = hint.trim(); | ||
| if (trimmed.length === 0) { | ||
| return; | ||
| } | ||
| this.pendingUserHints.push(trimmed); | ||
| this.lastUserHintAt = Date.now(); |
There was a problem hiding this comment.
The user-provided hint is added to the list of pending hints without proper sanitization, which could lead to a prompt injection vulnerability. The hint text is later embedded directly into prompts for the LLM. A malicious user could craft a hint containing special characters or directives (e.g., XML-like tags) to manipulate the prompt and potentially alter the agent's behavior.
According to the general rules, to prevent prompt injection, any user-provided context should be sanitized by escaping characters like < and >. The sanitization should be applied here in addUserHint to ensure all consumers of the hints receive the safe version.
| const trimmed = hint.trim(); | |
| if (trimmed.length === 0) { | |
| return; | |
| } | |
| this.pendingUserHints.push(trimmed); | |
| this.lastUserHintAt = Date.now(); | |
| const sanitized = hint.trim().replace(/</g, '<').replace(/>/g, '>'); | |
| if (sanitized.length === 0) { | |
| return; | |
| } | |
| this.pendingUserHints.push(sanitized); | |
| this.lastUserHintAt = Date.now(); |
References
- To prevent prompt injection, sanitize any additional context from hooks by escaping HTML-like tag characters such as
<and>. Although steering hints are not from hooks, they are user-provided context and the same sanitization principle applies.
This is a rebase / refactor of: #18783
This is a rebase / refactor of: #18783
Summary
This PR adds an experimental steering-hint flow so users can steer the agent while a turn is already in progress.
Refs #18782
What changed
flash-lite-helpermodel config alias.Experimental scope
This is intentionally experimental so contributors can try it end-to-end and provide feedback before we harden behavior and UX.
Validation
npm run -w @google/gemini-cli-core typechecknpm run -w @google/gemini-cli typechecknpm run -w @google/gemini-cli-core test -- src/services/modelConfig.golden.test.ts src/utils/flashLiteHelper.test.tsnpm run -w @google/gemini-cli test -- src/ui/hooks/useGeminiStream.test.tsx src/ui/components/HistoryItemDisplay.test.tsx