fix(core): avoid persisting interrupted response placeholder - #28939
Shivansh1980 wants to merge 4 commits into
Conversation
Replace the synthetic model-authored interruption turn with a transient user-side boundary in the next API request. This preserves tool results and role alternation without teaching the model to repeat the placeholder text. Apply the boundary to both regular request history and context-managed API history overrides, while keeping it out of durable agent history and chat recordings.
|
📊 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 refines how the system handles interrupted model responses following tool results. By moving from a persistent synthetic model turn to a transient, context-injected boundary, the change ensures that tool results and role alternation are preserved without polluting the model's training context or durable chat history. This approach improves reliability during session resumption and stream failures. 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors how interrupted model responses (dangling tool responses) are handled in GeminiChat. Instead of appending a dummy model turn with a placeholder to close the unanswered tool response, it now inserts a transient interruption boundary text directly into the subsequent user message parts during history or API history override preparation. The corresponding unit tests in geminiChat.test.ts have been updated and expanded to verify this new boundary insertion behavior under different context management configurations. I have no additional feedback to provide.
…response-boundary
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
…rrupted-tool-response-boundary
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the handling of interrupted or unanswered tool responses in GeminiChat. Instead of appending a dummy model turn placeholder to the history, it now inserts a transient interruption boundary message directly into the last user turn's parts, supporting both standard history and context-managed history overrides. The unit tests have been updated to reflect and validate this new behavior. There are no review comments to address, and the changes look solid.
|
This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
Summary
Fixes #28927.
After an interrupted tool-response turn, Gemini CLI persists this text as a synthetic model response:
The model can then repeat that placeholder after later tool calls, leaving the session unable to continue normally. This change replaces the persistent model-authored turn with a transient user-side boundary used only for the next API request.
Details
Root cause
PR #28700 prevented the next user message from being fused into an unanswered tool response by inserting a synthetic model turn:
That preserves role alternation, but it also stores the placeholder as ordinary model output in
agentHistoryand repeatedly sends it back to the model.Solution
When history ends with an unanswered
functionResponse:The outbound request becomes:
The boundary is applied to both standard curated history and context-managed
apiHistoryOverridehistory. It is never stored inagentHistory, chat recordings, or resumed session data. Multipart user messages remain together and in order after the boundary.Related Issues
How to Validate
Additional checks:
Coverage includes:
Pre-Merge Checklist
Validated locally on Windows after merging current
main. The focused suite, Prettier, file-scoped ESLint, core TypeScript check, and full build pass. Fullnpm run preflightreached lint setup and then stopped because Python/yamllint is not installed on this machine.The full core suite completed with 7,857 passing and 73 skipped tests. Its 22 failures are unrelated Windows environment/integration failures: 15 symlink-permission
EPERMfailures, six shell/sandbox environment failures, and one background-log timing failure. No failures occurred in the changed files.