Heuristic:24kchengYe MemoMind Thinking Budget Selection
| Knowledge Sources | |
|---|---|
| Domains | Retrieval, Performance |
| Last Updated | 2026-10-28 14:45 GMT |
Overview
The thinking_budget parameter (LOW=100, MID=300, HIGH=1000) controls graph traversal depth and reranking limits, trading latency for recall quality.
Description
The `thinking_budget` parameter maps a qualitative budget level (`Budget.LOW`, `Budget.MID`, `Budget.HIGH`) to a numeric value that controls multiple stages of the recall pipeline: graph traversal node exploration, retrieval limits, and the post-rerank truncation limit (`thinking_budget * 2`). The default is `Budget.MID` (300). This single parameter provides a unified latency/quality dial — higher budgets explore more graph nodes and rerank more candidates but increase recall latency.
Usage
Use this heuristic when tuning recall performance vs. quality. Use `Budget.LOW` for fast/simple queries (e.g., real-time chat suggestions), `Budget.MID` for standard recall (default), and `Budget.HIGH` for deep analysis queries (e.g., reflect agent multi-step retrieval).
The Insight (Rule of Thumb)
- Action: Set the `budget` parameter on recall/reflect calls to control graph traversal and reranking depth.
- Value: `LOW=100`, `MID=300` (default), `HIGH=1000`.
- Trade-off: Higher budget = more graph nodes explored, more candidates reranked, better recall but proportionally higher latency. LOW is ~3x faster than MID; MID is ~3x faster than HIGH.
- Compatibility: Affects graph retrieval (MPFP fan-out), reranking truncation (`budget * 2`), and token budget filtering input size.
Reasoning
Graph traversal (MPFP/link_expansion) is the most expensive part of recall — each additional hop multiplies the number of edges to load and score. The thinking_budget bounds this by limiting the number of nodes explored. The `* 2` multiplier on rerank limit (e.g., MID=300 → rerank top 600) provides a buffer — more candidates are reranked than ultimately returned, allowing the cross-encoder to re-sort before token budget filtering cuts the final set. The 3-tier system (100/300/1000) maps to ~3x latency steps, giving users a simple quality dial without exposing raw numbers.
Code Evidence
Budget mapping from `memory_engine.py:2388-2391`:
# Map budget enum to thinking_budget number (default to MID if None)
budget_mapping = {Budget.LOW: 100, Budget.MID: 300, Budget.HIGH: 1000}
effective_budget = budget if budget is not None else Budget.MID
thinking_budget = budget_mapping[effective_budget]
Post-rerank truncation from `memory_engine.py:2973-2975`:
# Step 5: Truncate to thinking_budget * 2 for token filtering
rerank_limit = thinking_budget * 2
top_scored = scored_results[:rerank_limit]
Budget passed to graph retrieval from `memory_engine.py:2681`:
thinking_budget, # passed to graph traversal as node exploration limit