From 194084d05864f545d62988b7b5e0b4ca57bf2272 Mon Sep 17 00:00:00 2001 From: Kailigithub <12250313+Kailigithub@users.noreply.github.com> Date: Sat, 18 Jul 2026 03:07:58 +0800 Subject: [PATCH] fix(background-review): add relevance gate to skill review prompt The per-session background review fork could write unrelated content into a skill via skill_manage(write_file) and skill_manage(patch) when the conversation produced research or notes that did not match the skill's documented purpose. The 'Be ACTIVE' pressure encouraged false positives: the fork saw research output and grafted it onto the nearest plausible skill. Closes #66350 --- agent/background_review.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/agent/background_review.py b/agent/background_review.py index c2ea87bd94e2..9de58092f319 100644 --- a/agent/background_review.py +++ b/agent/background_review.py @@ -183,6 +183,14 @@ def _digest_history(messages_snapshot: List[Dict], tail: int = 24) -> List[Dict] "ACTIVE — most sessions produce at least one skill update, even if " "small. A pass that does nothing is a missed learning opportunity, " "not a neutral outcome.\n\n" + "Relevance gate (mandatory): before any skill_manage(write_file), " + "skill_manage(patch), or skill_manage(create), verify that the " + "content is directly about the skill's documented purpose and scope. " + "A skill about X should not receive references about Y, even if Y is " + "interesting research. When in doubt, do not write — 'nothing to " + "save' is the correct outcome for sessions that did not involve the " + "skill's domain. Topical mismatch is the most common false positive; " + "refusing to write is a valid, valuable action.\n\n" "Target shape of the library: CLASS-LEVEL skills, each with a rich " "SKILL.md and a `references/` directory for session-specific detail. " "Not a long flat list of narrow one-session-one-skill entries. This " @@ -290,8 +298,15 @@ def _digest_history(messages_snapshot: List[Dict], tail: int = 24) -> List[Dict] "how you should behave? Save facts about the user and durable " "preferences with the memory tool.\n\n" "**Skills**: how to do this class of task. Be ACTIVE — most " - "sessions produce at least one skill update. A pass that does " - "nothing is a missed learning opportunity, not a neutral outcome.\n\n" + "sessions produce at least one skill update. A pass that " + "does nothing is a missed learning opportunity, not a neutral outcome.\n\n" + "Relevance gate (mandatory): before any skill_manage(write_file), " + "skill_manage(patch), or skill_manage(create), verify that the " + "content is directly about the skill's documented purpose and scope. " + "A skill about X should not receive references about Y, even if Y is " + "interesting research. When in doubt, do not write — 'nothing to " + "save' is the correct outcome. Topical mismatch is the most common " + "false positive; refusing to write is a valid, valuable action.\n\n" "Target shape of the skill library: CLASS-LEVEL skills with a rich " "SKILL.md and a `references/` directory for session-specific detail. " "Not a long flat list of narrow one-session-one-skill entries.\n\n"