feat(skills): exclude_keywords veto in skill activation scoring#688
feat(skills): exclude_keywords veto in skill activation scoring#688nick-stebbings wants to merge 2 commits intonearai:mainfrom
Conversation
Add exclude_keywords field to ActivationCriteria. If any exclude keyword is present in the user message, the skill scores 0 regardless of keyword or pattern matches — prevents cross-skill interference. Behaviour: exclude_keywords is a hard veto. Even an exact skill name match gets vetoed if an exclude keyword is also present. This is intentional; partial exclusion (score reduction) would create unpredictable interference behaviour. Example use case: a writing skill with keywords ["write", "draft"] and exclude_keywords ["route", "redirect"] will not activate on messages like "don't route this to the writing agent". Changes: - ActivationCriteria: new exclude_keywords field (serde default) - LoadedSkill: new lowercased_exclude_keywords (preprocessed at load) - selector.rs: early-return 0 in score_skill() on veto match - registry.rs: populate lowercased_exclude_keywords during loading - Test helpers updated across mod.rs, selector.rs, attenuation.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 skill activation system by introducing a robust exclusion mechanism. It allows skill definitions to specify keywords that, if present in a user's message, will completely prevent that skill from activating, regardless of other matching criteria. This feature is designed to eliminate undesirable cross-skill interference and improve the predictability of skill selection. 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 exclude_keywords feature for skills, allowing a skill's activation score to be set to zero if a user's message contains any of these keywords. While the implementation correctly adds the necessary fields and applies the veto logic, the new exclude_keywords field lacks resource limits (truncation and minimum length) applied to other activation criteria like keywords and tags. This omission could be exploited to cause performance degradation (Denial of Service) during message processing, and the current keyword matching logic can lead to false positives, especially with empty strings. I recommend updating the enforce_limits method in src/skills/mod.rs to include exclude_keywords and considering more robust keyword detection. Additionally, there are a couple of suggestions to improve code clarity and reduce duplication by consolidating repeated logic into helper functions.
…er, use any() - Add exclude_keywords to enforce_limits() with same min-length and cap rules as keywords — prevents empty string always-match and unbounded lists - Extract to_lowercase_vec() helper to deduplicate three identical blocks - Use idiomatic any() iterator instead of for loop in score_skill veto check Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Updated: Added |
Summary
Adds
exclude_keywordssupport to the skill activation scoring pipeline. If any exclude keyword is present in the user message, the skill scores 0 regardless of keyword or pattern matches.This prevents cross-skill interference — e.g. a writing skill with
keywords: ["write", "draft"]andexclude_keywords: ["route", "redirect"]will not activate on messages like "don't route this to the writing agent".Behaviour note:
exclude_keywordsis a hard veto — if any exclude keyword matches, the skill scores 0 regardless of keyword or pattern matches. This is intentional; partial exclusion (score reduction rather than veto) would create unpredictable interference behaviour.Changes
mod.rs: Newexclude_keywordsfield onActivationCriteria, newlowercased_exclude_keywordsonLoadedSkillselector.rs: Early-return 0 inscore_skill()if any exclude keyword matchesregistry.rs: Populatelowercased_exclude_keywordsfrom manifest at load time (follows existing pattern of preprocessing at load time, not score time)mod.rs,selector.rs,attenuation.rsSKILL.md format addition
Test plan
exclude_keywords: ["route"]scores 0 when message contains "route"to_lowercase()at load time)cargo checkandcargo testpass🤖 Generated with Claude Code