feat(core): exempt high-signal tools from output masking#18545
feat(core): exempt high-signal tools from output masking#18545abhipatel12 merged 2 commits intomainfrom
Conversation
Ensures that tools providing essential instructions or state transitions (activate_skill, save_memory, ask_user, plan_mode) are never masked, preserving critical context for the model. - Added EXEMPT_TOOLS set to ToolOutputMaskingService - Updated backward scan to skip exempt tool outputs - Added comprehensive unit tests for exemption logic
Summary of ChangesHello @abhipatel12, 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 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 exemption list for high-signal tools to prevent their output from being masked by the ToolOutputMaskingService. The change is well-implemented by creating a Set of exempt tool names and skipping them during the masking process, which correctly ensures that critical context from tools like activate_skill and save_memory is preserved across long sessions. The accompanying test case is thorough and correctly validates that exempt tools are never masked, while other bulky tool outputs are handled as before. The implementation is clean, efficient, and correct.
|
Size Change: +364 B (0%) Total Size: 23.9 MB ℹ️ View Unchanged
|
Summary
This PR ensures that high-signal tools (skills, memory, user input, and state transitions) are exempt from context window masking.
Previously, the
ToolOutputMaskingServicewould mask any tool output older than the protection window once prunable tokens exceeded the threshold. This was problematic for tools likeactivate_skill, where the model needs the instruction set and resource mappings to function correctly across long-running sessions.Details
EXEMPT_TOOLSset containingactivate_skill,save_memory,ask_user,enter_plan_mode, andexit_plan_mode.ToolOutputMaskingServiceto skip masking for anyfunctionResponsefrom these tools.Related Issues
N/A
How to Validate
npm test -w @google/gemini-cli-core -- src/services/toolOutputMaskingService.test.tsnpm run preflightto verify the entire monorepo.Pre-Merge Checklist