fix(cli): record skill activation tool calls in chat history#23203
fix(cli): record skill activation tool calls in chat history#23203NTaylorMullen merged 4 commits intomainfrom
Conversation
- Ensure that /<skill-name> slash commands (which use activate_skill) are recorded in the GeminiChat history. - Manually add both the synthetic model turn (the function call) and the user turn (the function response) to the history. - This allows the model to recognize activated skills and their instructions in subsequent turns. - Narrows the record to only ACTIVATE_SKILL_TOOL_NAME to avoid redundant history entries for other client-initiated tools like save_memory. - Includes a regression test in useGeminiStream.test.tsx. - Fixes pre-existing build issues (typo in fileSystemService.ts and unused variables in tests). Fixes https://b.corp.google.com/issues/493593969
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 enhances the Gemini CLI's chat history management by ensuring that client-initiated skill activations are properly recorded. Previously, these actions were not visible to the model, leading to a lack of context. The changes introduce a mechanism to manually add both the skill activation call and its response to the chat history, allowing the model to accurately track and respond to active skills. This improves the model's contextual understanding and overall user experience. 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 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. Footnotes
|
| // Only manually record skill activations in the chat history. | ||
| // Other client-initiated tools (like save_memory) update the system | ||
| // prompt/context and don't strictly need to be in the history. | ||
| if (tool.request.name !== ACTIVATE_SKILL_TOOL_NAME) { |
There was a problem hiding this comment.
Scoped this specific to activate skill for now to not have any adverse consequences
There was a problem hiding this comment.
Code Review
This pull request correctly addresses the issue of client-initiated skill activations not being recorded in the chat history. By manually adding the synthetic model and user turns for activate_skill calls, the model will now have the necessary context for subsequent interactions. The addition of targeted tests to verify this behavior for both activate_skill and other tools like save_memory is a good practice.
I have one suggestion regarding unhandled promises which could improve the robustness of the implementation.
|
Size Change: +638 B (0%) Total Size: 26.1 MB
ℹ️ View Unchanged
|
- Addresses scidomino's review comment to avoid 'any' in the test file. - Preserves fix for unhandled promises in useGeminiStream.ts from previous commit. Fixes https://b.corp.google.com/issues/493593969
- Fixes 'TrackedToolCall[] is not assignable to CompletedToolCall[]' by typing stopExecutionToolCalls as TrackedCompletedToolCall[]. - Fixes 'Cannot invoke an object which is possibly null' by adding null checks before calling capturedOnComplete. Fixes https://b.corp.google.com/issues/493593969
Summary
Ensure that skill activation tool calls triggered by slash commands are recorded in the GeminiChat history. This allows the model to recognize activated skills and their instructions in subsequent turns.
Details
GeminiChathistory.activate_skillcalls.save_memoryare excluded to avoid redundancy, as they already update the system context.fileSystemService.tsand unused variables in tests.Related Issues
Fixes https://b.corp.google.com/issues/493593969
How to Validate
npm installandnpm run build.npx vitest packages/cli/src/ui/hooks/useGeminiStream.test.tsx./docs-writer).Pre-Merge Checklist