Przeglądaj źródła

[openclaw]不对slash command的启动指令搜索知识库

kevin.yang 1 dzień temu
rodzic
commit
2dbb181145
1 zmienionych plików z 10 dodań i 0 usunięć
  1. 10 0
      knowhub/skill/openclaw-plugin/index.ts

+ 10 - 0
knowhub/skill/openclaw-plugin/index.ts

@@ -50,6 +50,8 @@ const PROMPT_INJECTION_PATTERNS = [
   /<\s*(system|assistant|developer|tool)\b/i,
 ];
 
+const SESSION_RESET_PREFIX = "A new session was started via /new or /reset.";
+
 function looksLikePromptInjection(text: string): boolean {
   const normalized = text.replace(/\s+/g, " ").trim();
   return PROMPT_INJECTION_PATTERNS.some((pattern) => pattern.test(normalized));
@@ -513,12 +515,20 @@ const knowhubPlugin = {
     if (cfg.reminderMode !== "off") {
       api.on("before_prompt_build", async (event, ctx) => {
         try {
+          if (ctx.trigger && ctx.trigger !== "user") {
+            return;
+          }
+
           const stripped = stripLeadingInboundMetadata(event.prompt);
           const userPrompt = normalizeStrippedInboundText(stripped).trim();
           if (!userPrompt || userPrompt.length < 5 || userPrompt.startsWith("/")) {
             return;
           }
 
+          if (userPrompt.startsWith(SESSION_RESET_PREFIX)) {
+            return;
+          }
+
           const topK = 5;
           const minScore = 3;