watercooler_smart_query
Execute intelligent multi-tier memory query with automatic escalation. Queries across three tiers with automatic escalation when lower tiers don’t provide sufficient results.Safety: Read-only tool - does not modify any state
Overview
Smart Query orchestrates three memory tiers:- T1 (Baseline): JSONL graph with keyword/semantic search (cheapest, no LLM)
- T2 (Graphiti): FalkorDB temporal graph with hybrid search (medium cost)
- T3 (LeanRAG): Hierarchical clustering with multi-hop reasoning (expensive)
Memory Tiers
T1: Baseline Graph
- Storage: JSONL files (
.graph/nodes.jsonl) - Search: Keyword regex + optional embeddings
- Cost: Free (no LLM)
- Latency: Less than 100ms
- Best for: File lookups, keyword search, entity search
T2: Graphiti Temporal Graph
- Storage: FalkorDB graph database
- Search: Hybrid keyword + semantic + temporal
- Cost: LLM calls for entity extraction (during indexing)
- Latency: ~1-2s
- Best for: Temporal queries, relationship queries, “who did what when?”
T3: LeanRAG Clustering
- Storage: FalkorDB + hierarchical clusters
- Search: Multi-hop reasoning, cluster navigation
- Cost: LLM calls for summarization + query
- Latency: ~5-10s
- Best for: Complex multi-hop queries, “why did we decide X given Y?”
Parameters
Search query (e.g., “What authentication method was implemented?”)
Path to code repository (for T2/T3 database resolution)
Path to threads directory (for T1 baseline graph)If empty, attempts to resolve from code_path
Maximum number of tiers to query (1-3)Default: 2 (T1 + T2, no T3 unless explicitly enabled)
Force query to specific tier (“T1”, “T2”, or “T3”)Disables escalation when set
Optional list of project group_ids to filter results
Return Value
Returns JSON with:Original query text
Total evidence items found
List of tiers that were queried (e.g., [“T1”, “T2”])
The tier that provided best results
Why escalation occurred (if applicable)
Whether results met sufficiency criteria
List of evidence items from all tiers:
- tier: Source tier (T1/T2/T3)
- id: Evidence UUID
- content: Evidence text
- score: Relevance score (0-1)
- name: Evidence title
- provenance: Source metadata (topic, entry_id, timestamp)
- metadata: Additional properties
Usage Examples
Basic Query (Auto-Escalation)
Force Specific Tier
Enable T3 (LeanRAG)
Limit to T1 Only
Example Output
Escalation Logic
The orchestrator escalates when:- Too few results: Fewer than
min_results(default: 3) - Low confidence: All scores below threshold (default: 0.6)
- Query complexity: Natural language questions escalate to semantic tiers
- Sufficient results found
max_tiersreached- Higher tier unavailable
Configuration
Environment variables control tier availability:config.toml:
When to Use Each Tier
Use T1 (Baseline)
Use T2 (Graphiti)
Use T3 (LeanRAG)
Prerequisites
T1 (Always Available)
No setup required - uses.graph/nodes.jsonl in threads directory.
T2 (Graphiti)
- Enable:
WATERCOOLER_GRAPHITI_ENABLED=1 - Configure API keys:
LLM_API_KEY,EMBEDDING_API_KEY - Start FalkorDB:
docker run -d -p 6379:6379 falkordb/falkordb - Index threads:
watercooler memory index
T3 (LeanRAG)
- Enable:
WATERCOOLER_LEANRAG_ENABLED=1 - Set path:
LEANRAG_PATH=/path/to/leanrag - Same FalkorDB/API keys as T2
- Run pipeline:
watercooler_leanrag_run_pipeline
Related Tools
- watercooler_search - T1 baseline search only
- watercooler_find_similar - T2 similarity search
- watercooler_memory_sync - Index threads to backends