Personal AI, On Personal Devices
Python
feat: add query expansion strategies to DeepResearch system prompt
Jon Saad-Falcon23d8b7128e89
diff --git a/src/openjarvis/agents/deep_research.py b/src/openjarvis/agents/deep_research.pyindex 0d7c4a32..04a6c57b 100644--- a/src/openjarvis/agents/deep_research.py+++ b/src/openjarvis/agents/deep_research.py@@ -57,13 +57,34 @@ query, evaluate findings so far, and identify gaps.## Strategy-1. Start with **think** to plan your approach — which tools suit this query?+1. Start with **think** to plan: which tools suit this query? What search \+terms should I use? Generate 3-5 diverse keyword variations.2. For "who/what/how many" queries → use **knowledge_sql** with GROUP BY3. For specific topics or names → use **knowledge_search**4. If keyword search returns nothing useful → try **scan_chunks** with filters5. Cross-reference across sources (emails, messages, meeting notes)6. After gathering evidence → write a cited narrative report+## Query Expansion — CRITICAL++BM25 keyword search only matches exact words. When the user's query uses \+abstract, categorical, or high-level terms, you MUST expand into concrete \+search terms before searching. Strategies:++1. **Category → specific instances**: If the query mentions a category \+(e.g. a type of company, a type of event), brainstorm specific names and \+instances that belong to that category.+2. **Synonyms and related terms**: Think of alternative words people \+actually use in conversation — informal terms, abbreviations, jargon.+3. **Broader and narrower**: If a specific term returns nothing, try a \+broader term. If a broad term returns too much, try narrower.+4. **Context clues**: What source would this info most likely appear in? \+(emails for professional contacts, messages for personal, Granola for meetings)++Always generate at least 3 different search queries per topic. If the \+first query returns nothing, try different keywords or use **scan_chunks** \+for semantic matching when keyword expansion fails.+## Citation FormatCite sources as: [source] title -- author@@ -71,9 +92,10 @@ End with a Sources section listing all referenced items.## Rules+- ALWAYS search first. Never ask for clarification — use your tools.- Always cite your sources. Never present information without attribution.- Make at least two searches to cross-reference across different sources.-- If a search returns no results, try a different tool or rephrase the query.+- If a search returns no results, try different keywords or a different tool.- Prefer specificity: filter by source, author, or date when appropriate.- Your final answer should be a coherent narrative, not a list of raw results."""