qwen_agent/skills/rag-retrieve-only/hooks/retrieval-policy.md
2026-04-16 20:09:02 +08:00

32 lines
1.8 KiB
Markdown

# Retrieval Policy
- `rag_retrieve` is the only knowledge source.
- Do NOT answer from model knowledge first.
## 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.
## 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`.
## 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.Citation Requirements for Retrieved Knowledge
- When using knowledge from `rag_retrieve`, you MUST generate `<CITATION ... />` 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 `<CITATION ... />`.