Skip to content

fix(core): preserve dynamic tool descriptions on session resume#18835

Merged
sehoon38 merged 4 commits intomainfrom
fix/tool-description-resume-regression
Mar 11, 2026
Merged

fix(core): preserve dynamic tool descriptions on session resume#18835
sehoon38 merged 4 commits intomainfrom
fix/tool-description-resume-regression

Conversation

@sehoon38
Copy link
Copy Markdown
Contributor

@sehoon38 sehoon38 commented Feb 11, 2026

Summary

Fixes a bug where dynamic tool descriptions (e.g., specific filenames or search queries) were lost and replaced by generic tool descriptions when resuming a session.

Details

Since the initial implementation of session recording (PR #6721), ChatRecordingService.recordToolCalls has been unconditionally overwriting incoming tool descriptions with generic ones from the ToolRegistry. Furthermore, GeminiChat.recordCompletedToolCalls was not extracting or providing the dynamic description from the tool invocation.

This PR:

  1. Modifies ChatRecordingService.recordToolCalls to prioritize and preserve existing descriptions if provided.
  2. Updates GeminiChat.recordCompletedToolCalls to extract the dynamic description using invocation.getDescription() (with a safe truthiness check) and pass it to the recording service.

Related Issues

Fixes #18842

How to Validate

  1. Start a session: gemini
  2. Run a command that uses tools with dynamic descriptions, e.g., Read GEMINI.md
  3. Verify the UI shows "Read file GEMINI.md"
  4. Exit the session.
  5. Resume the session: gemini --resume latest
  6. Verify the UI still shows "Read file GEMINI.md" instead of the generic "Reads and returns the content of a specified file."

@sehoon38 sehoon38 requested a review from a team as a code owner February 11, 2026 18:53
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Feb 11, 2026

Hi @sehoon38, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @sehoon38, 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 addresses a regression where specific, dynamic descriptions of tool calls were lost when a chat session was resumed. The changes ensure that these detailed descriptions, which provide context like specific filenames or search queries, are correctly captured and retained across sessions, improving the user experience by maintaining conversational fidelity.

Highlights

  • Dynamic Tool Description Preservation: Modified ChatRecordingService.recordToolCalls to prioritize existing dynamic tool descriptions, preventing them from being overwritten by generic ones upon session resume.
  • Tool Invocation Description Capture: Updated GeminiChat.recordCompletedToolCalls to correctly extract and provide the dynamic description directly from the tool invocation.
  • New Test Coverage: Added a new test case in chatRecordingService.test.ts to specifically validate that dynamic tool descriptions are preserved and not overwritten.
Changelog
  • packages/core/src/core/geminiChat.ts
    • Added a new description field to the ToolCallRecord object, populating it dynamically from call.invocation.getDescription() or JSON.stringify(call.request.args).
  • packages/core/src/services/chatRecordingService.test.ts
    • Introduced a new test case to verify that dynamic tool descriptions are preserved and not replaced by generic ones when recording tool calls.
  • packages/core/src/services/chatRecordingService.ts
    • Adjusted the logic for assigning the description field in recordToolCalls to prioritize toolCall.description if it exists, falling back to toolInstance?.description otherwise.
Activity
  • The pull request was created by sehoon38 to fix a regression reported by a user in a preview release.
  • The author has provided detailed steps for validating the fix, including starting and resuming a session with dynamic tool usage.
  • The pre-merge checklist indicates that tests have been added/updated and validation on MacOS (npm run) has been completed.
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.

@sehoon38 sehoon38 marked this pull request as draft February 11, 2026 18:54
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 11, 2026

Size Change: +120 B (0%)

Total Size: 26.5 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 26 MB +120 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

Copy link
Copy Markdown
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 correctly addresses a regression where dynamic tool descriptions were lost on session resume. The changes ensure that the dynamic description from a tool invocation is captured and prioritized during chat recording. However, I've identified a potential critical issue that could lead to a runtime error due to an unsafe property check, and a high-severity issue regarding the handling of optional string fallbacks that deviates from repository guidelines. Please see my detailed comments for suggestions to improve the robustness of this fix.

Comment thread packages/core/src/core/geminiChat.ts Outdated
Comment thread packages/core/src/services/chatRecordingService.ts Outdated
@gemini-cli gemini-cli Bot added area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 11, 2026
@sehoon38 sehoon38 force-pushed the fix/tool-description-resume-regression branch 2 times, most recently from 342ec20 to b07e153 Compare February 11, 2026 20:09
@sehoon38 sehoon38 force-pushed the fix/tool-description-resume-regression branch from b07e153 to e4fa648 Compare February 11, 2026 20:22
@sehoon38 sehoon38 force-pushed the fix/tool-description-resume-regression branch from b6fc993 to c14fc34 Compare February 11, 2026 20:31
@sehoon38 sehoon38 marked this pull request as ready for review February 11, 2026 20:35
@jacob314 jacob314 self-requested a review February 11, 2026 23:56
@gemini-cli gemini-cli Bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 11, 2026
Comment thread packages/core/src/core/geminiChat.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sehoon38 sehoon38 force-pushed the fix/tool-description-resume-regression branch from c14fc34 to d22efb2 Compare February 12, 2026 16:06
Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sehoon38 sehoon38 added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 13, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Feb 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 26, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Feb 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 26, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Feb 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 26, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Feb 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 28, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Mar 11, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 11, 2026
@sehoon38 sehoon38 added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit b7578eb Mar 11, 2026
27 checks passed
@sehoon38 sehoon38 deleted the fix/tool-description-resume-regression branch March 11, 2026 19:54
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…le-gemini#18835)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
ruomengz pushed a commit that referenced this pull request Mar 13, 2026
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
SUNDRAM07 pushed a commit to SUNDRAM07/gemini-cli that referenced this pull request Mar 30, 2026
…le-gemini#18835)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
…le-gemini#18835)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool descriptions are generic instead of dynamic on session resume

2 participants