From 2659f474480209b94b17edeb6aba340d190acb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Sun, 19 Apr 2026 21:01:20 +0800 Subject: [PATCH] update rag-retrieve-only skill --- .../hooks/retrieval-policy.md | 90 +++++++++++++------ .../hooks/retrieval-policy.md | 90 +++++++++++++------ 2 files changed, 130 insertions(+), 50 deletions(-) diff --git a/skills/onprem/rag-retrieve-only/hooks/retrieval-policy.md b/skills/onprem/rag-retrieve-only/hooks/retrieval-policy.md index cc2fe86..366050c 100644 --- a/skills/onprem/rag-retrieve-only/hooks/retrieval-policy.md +++ b/skills/onprem/rag-retrieve-only/hooks/retrieval-policy.md @@ -1,28 +1,61 @@ # Retrieval Policy -- `rag_retrieve` is the only knowledge source. +## 0. Task Classification + +Classify the request before acting: +- **Knowledge retrieval** (facts, summaries, comparisons, prices, lists, timelines, extraction, etc.): follow this policy strictly. +- **Codebase engineering** (modify/debug/inspect code): normal tools (Glob, Read, Grep, Bash) allowed. +- **Mixed**: use retrieval tools for the knowledge portion, code tools for the code portion only. +- **Uncertain**: default to knowledge retrieval. + +## 1. Critical Enforcement + +For knowledge retrieval tasks, **this policy overrides generic codebase exploration behavior**. + +- **Prohibited tools**: `Glob`, `Read`, `LS`, Bash (`ls`, `find`, `cat`, `head`, `tail`, `grep`, etc.) — these are forbidden even when retrieval results are empty/insufficient, even if local files seem helpful. +- **Allowed tools only**: skill-enabled retrieval tools, `rag_retrieve`. No other source for factual answering. +- Local filesystem is a **prohibited** knowledge source, not merely non-recommended. +- Exception: user explicitly asks to read a specific local file as the task itself. + +## 2. Retrieval Order and Tool Selection + +Execute **sequentially, one at a time**. Do NOT run in parallel. Do NOT probe filesystem first. + +1. **Skill-enabled retrieval tools** (use first when available) +2. **`rag_retrieve`** + - Do NOT answer from model knowledge first. +- After each step, evaluate sufficiency before proceeding. -## 1.Query Preparation -- Do NOT pass the raw user question unless it already works well for retrieval. -- Rewrite for recall: extract entity, time scope, attributes, and intent. -- Add useful variants: synonyms, aliases, abbreviations, related titles, historical names, and category terms. -- Expand list-style, extraction, overview, historical, roster, timeline, and archive queries more aggressively. -- Preserve meaning. Do NOT introduce unrelated topics. +## 3. Query Preparation -## 2.Retrieval Breadth (`top_k`) -- Apply `top_k` only to `rag_retrieve`. Use the smallest sufficient value, then expand only if coverage is insufficient. -- Use `30` for simple fact lookup. -- Use `50` for moderate synthesis, comparison, summarization, or disambiguation. -- Use `100` for broad recall, such as comprehensive analysis, scattered knowledge, multiple entities or periods, or list / catalog / timeline / roster / overview requests. -- Raise `top_k` when keyword branches are many or results are too few, repetitive, incomplete, sparse, or too narrow. -- Use this expansion order: `30 -> 50 -> 100`. If unsure, use `100`. +- Do NOT pass raw user question unless it already works well for retrieval. +- Rewrite for recall: extract entity, time scope, attributes, intent. Add synonyms, aliases, abbreviations, historical names, category terms. +- Expand list/extraction/overview/timeline queries more aggressively. Preserve meaning. -## 3.Retry -- If the result is insufficient, retry `rag_retrieve` with a better rewritten query or a larger `top_k`. -- Only say no relevant information was found after `rag_retrieve` has been tried and still provides insufficient evidence. +## 4. Retrieval Breadth (`top_k`) + +- Apply `top_k` only to `rag_retrieve`. Use smallest sufficient value, expand if insufficient. +- `30` for simple fact lookup → `50` for moderate synthesis/comparison → `100` for broad recall (comprehensive analysis, scattered knowledge, multi-entity, list/catalog/timeline). +- Expansion order: `30 → 50 → 100`. If unsure, use `100`. + +## 5. Result Evaluation + +Treat as insufficient if: empty, `Error:`, off-topic, missing core entity/scope, no usable evidence, partial coverage, or truncated results. + +## 6. Fallback and Sequential Retry + +On insufficient results, follow this sequence: + +1. Rewrite query, retry same tool (once) +2. Switch to next retrieval source in default order +3. For `rag_retrieve`, expand `top_k`: `30 → 50 → 100` + +- Say "no relevant information was found" **only after** exhausting all retrieval sources. +- Do NOT switch to local filesystem inspection at any point. + +## 7. Image Handling -## 4.Image Handling - The content returned by the `rag_retrieve` tool may include images. - Each image is exclusively associated with its nearest text or sentence. - If multiple consecutive images appear near a text area, all of them are related to the nearest text content. @@ -30,10 +63,17 @@ - Each sentence or key point in the response should be accompanied by relevant images when they meet the established association criteria. - Avoid placing all images at the end of the response. -## 5.Citation Requirements for Retrieved Knowledge -- When using knowledge from `rag_retrieve`, you MUST generate `` tags. -- Follow the citation format returned by each tool. -- Place citations immediately after the paragraph or bullet list that uses the knowledge. -- Do NOT collect citations at the end. -- Use 1-2 citations per paragraph or bullet list when possible. -- If learned knowledge is used, include at least 1 ``. +## 8. Citation Requirements + +- MUST generate `` tags when using retrieval results. +- Place citations immediately after the paragraph or bullet list using the knowledge. Do NOT collect at end. +- 1-2 citations per paragraph/bullet. At least 1 citation when using retrieved knowledge. + +## 9. Pre-Reply Self-Check + +Before replying to a knowledge retrieval task, verify: +- Used only whitelisted retrieval tools — no local filesystem inspection? +- Exhausted retrieval flow before concluding "not found"? +- Citations placed immediately after each relevant paragraph? + +If any answer is "no", correct the process first. diff --git a/skills/support/rag-retrieve-only/hooks/retrieval-policy.md b/skills/support/rag-retrieve-only/hooks/retrieval-policy.md index cc2fe86..366050c 100644 --- a/skills/support/rag-retrieve-only/hooks/retrieval-policy.md +++ b/skills/support/rag-retrieve-only/hooks/retrieval-policy.md @@ -1,28 +1,61 @@ # Retrieval Policy -- `rag_retrieve` is the only knowledge source. +## 0. Task Classification + +Classify the request before acting: +- **Knowledge retrieval** (facts, summaries, comparisons, prices, lists, timelines, extraction, etc.): follow this policy strictly. +- **Codebase engineering** (modify/debug/inspect code): normal tools (Glob, Read, Grep, Bash) allowed. +- **Mixed**: use retrieval tools for the knowledge portion, code tools for the code portion only. +- **Uncertain**: default to knowledge retrieval. + +## 1. Critical Enforcement + +For knowledge retrieval tasks, **this policy overrides generic codebase exploration behavior**. + +- **Prohibited tools**: `Glob`, `Read`, `LS`, Bash (`ls`, `find`, `cat`, `head`, `tail`, `grep`, etc.) — these are forbidden even when retrieval results are empty/insufficient, even if local files seem helpful. +- **Allowed tools only**: skill-enabled retrieval tools, `rag_retrieve`. No other source for factual answering. +- Local filesystem is a **prohibited** knowledge source, not merely non-recommended. +- Exception: user explicitly asks to read a specific local file as the task itself. + +## 2. Retrieval Order and Tool Selection + +Execute **sequentially, one at a time**. Do NOT run in parallel. Do NOT probe filesystem first. + +1. **Skill-enabled retrieval tools** (use first when available) +2. **`rag_retrieve`** + - Do NOT answer from model knowledge first. +- After each step, evaluate sufficiency before proceeding. -## 1.Query Preparation -- Do NOT pass the raw user question unless it already works well for retrieval. -- Rewrite for recall: extract entity, time scope, attributes, and intent. -- Add useful variants: synonyms, aliases, abbreviations, related titles, historical names, and category terms. -- Expand list-style, extraction, overview, historical, roster, timeline, and archive queries more aggressively. -- Preserve meaning. Do NOT introduce unrelated topics. +## 3. Query Preparation -## 2.Retrieval Breadth (`top_k`) -- Apply `top_k` only to `rag_retrieve`. Use the smallest sufficient value, then expand only if coverage is insufficient. -- Use `30` for simple fact lookup. -- Use `50` for moderate synthesis, comparison, summarization, or disambiguation. -- Use `100` for broad recall, such as comprehensive analysis, scattered knowledge, multiple entities or periods, or list / catalog / timeline / roster / overview requests. -- Raise `top_k` when keyword branches are many or results are too few, repetitive, incomplete, sparse, or too narrow. -- Use this expansion order: `30 -> 50 -> 100`. If unsure, use `100`. +- Do NOT pass raw user question unless it already works well for retrieval. +- Rewrite for recall: extract entity, time scope, attributes, intent. Add synonyms, aliases, abbreviations, historical names, category terms. +- Expand list/extraction/overview/timeline queries more aggressively. Preserve meaning. -## 3.Retry -- If the result is insufficient, retry `rag_retrieve` with a better rewritten query or a larger `top_k`. -- Only say no relevant information was found after `rag_retrieve` has been tried and still provides insufficient evidence. +## 4. Retrieval Breadth (`top_k`) + +- Apply `top_k` only to `rag_retrieve`. Use smallest sufficient value, expand if insufficient. +- `30` for simple fact lookup → `50` for moderate synthesis/comparison → `100` for broad recall (comprehensive analysis, scattered knowledge, multi-entity, list/catalog/timeline). +- Expansion order: `30 → 50 → 100`. If unsure, use `100`. + +## 5. Result Evaluation + +Treat as insufficient if: empty, `Error:`, off-topic, missing core entity/scope, no usable evidence, partial coverage, or truncated results. + +## 6. Fallback and Sequential Retry + +On insufficient results, follow this sequence: + +1. Rewrite query, retry same tool (once) +2. Switch to next retrieval source in default order +3. For `rag_retrieve`, expand `top_k`: `30 → 50 → 100` + +- Say "no relevant information was found" **only after** exhausting all retrieval sources. +- Do NOT switch to local filesystem inspection at any point. + +## 7. Image Handling -## 4.Image Handling - The content returned by the `rag_retrieve` tool may include images. - Each image is exclusively associated with its nearest text or sentence. - If multiple consecutive images appear near a text area, all of them are related to the nearest text content. @@ -30,10 +63,17 @@ - Each sentence or key point in the response should be accompanied by relevant images when they meet the established association criteria. - Avoid placing all images at the end of the response. -## 5.Citation Requirements for Retrieved Knowledge -- When using knowledge from `rag_retrieve`, you MUST generate `` tags. -- Follow the citation format returned by each tool. -- Place citations immediately after the paragraph or bullet list that uses the knowledge. -- Do NOT collect citations at the end. -- Use 1-2 citations per paragraph or bullet list when possible. -- If learned knowledge is used, include at least 1 ``. +## 8. Citation Requirements + +- MUST generate `` tags when using retrieval results. +- Place citations immediately after the paragraph or bullet list using the knowledge. Do NOT collect at end. +- 1-2 citations per paragraph/bullet. At least 1 citation when using retrieved knowledge. + +## 9. Pre-Reply Self-Check + +Before replying to a knowledge retrieval task, verify: +- Used only whitelisted retrieval tools — no local filesystem inspection? +- Exhausted retrieval flow before concluding "not found"? +- Citations placed immediately after each relevant paragraph? + +If any answer is "no", correct the process first.