# Tool Selection Reference

Use this reference when deciding whether to route a memory or retrieval task toward MemPalace, QMD, or a combined flow.

## Core Distinction

MemPalace is the **persistent memory system**. It is strongest when the agent needs conversation history, previous decisions, long-lived project memory, or proactive memory capture across sessions.

QMD is the **precision retrieval system**. It is strongest when the agent needs to search indexed markdown or code-adjacent documents with exact identifiers, technical jargon, semantic code questions, hybrid retrieval, or batch document pull.

## Practical Routing

| Situation | Preferred System | Why |
|---|---|---|
| "What did we decide last week?" | MemPalace | This is memory recall over conversations or durable project history. |
| "Why did we switch auth providers?" | MemPalace first, then QMD if docs are needed | Rationale may live in conversation history, issue notes, or prior decisions. |
| "Find the RwLock unwrap fix" | QMD | Exact code phrase and technical vocabulary benefit from code-oriented retrieval. |
| "Search the docs for rate limiter behavior" | QMD | This is markdown/document search with lexical and semantic matching. |
| "What files explain the indexing pipeline, and what did we previously say about it?" | QMD then MemPalace | First retrieve the technical documents, then recover historical reasoning. |
| "Save what we just learned for later" | MemPalace | This is durable memory capture, not just search. |

## Embedding Heuristic

When repository or agent memory files contain embedding metadata, use it as a routing signal.

| Signal | Interpretation |
|---|---|
| `all-MiniLM-L6-v2`, `384`, `ONNX`, Chroma-style language | Strong signal for MemPalace-style lightweight conversational retrieval |
| `embeddinggemma-300M`, `768`, `GGUF`, long-context vector index language | Strong signal for QMD-style deeper semantic retrieval |
| Indexing of markdown, docs, transcripts, collections, BM25, reranking | Strong signal for QMD |
| Mining conversations, palace, rooms, wings, drawers, wake-up context, auto-save hooks | Strong signal for MemPalace |

## Confidence Rules

| Confidence | Requirement |
|---|---|
| High | Direct mention of tool name or embedding model in memory/config/docs |
| Medium | Indirect mention of dimensions, format, or index workflow matching one system |
| Low | Only task wording suggests a system, but no repository or memory evidence is found |

## Fallback Rule

If the task blends code retrieval and historical decision recall, use a **combined flow**. Start with the system most likely to answer the dominant need, then use the other system to fill gaps.
