Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:24kchengYe MemoMind Consolidation LLM Batch Sizing

From Leeroopedia
Knowledge Sources
Domains Consolidation, LLM_Optimization
Last Updated 2026-10-28 14:45 GMT

Overview

Consolidation batches 8 facts per LLM call (default) and 50 memories per DB batch to balance LLM token efficiency with observation quality.

Description

Memory consolidation synthesizes raw facts into higher-level observations via LLM calls. Two batch sizes control the pipeline: `consolidation_batch_size=50` (memories loaded per DB batch, an internal memory optimization) and `consolidation_llm_batch_size=8` (facts per LLM call). When `llm_batch_size=1`, each fact gets its own LLM call (no batching). When `>1`, facts are grouped by tag group first, then sub-batched into groups of `llm_batch_size` — respecting both tag grouping and the batch limit. This balances LLM token efficiency (fewer calls with more context) against observation quality (too many facts per call dilutes synthesis focus).

Usage

Use this heuristic when tuning consolidation throughput and quality. Increase `HINDSIGHT_API_CONSOLIDATION_LLM_BATCH_SIZE` for faster consolidation (fewer LLM calls) at the risk of less focused observations. Set to 1 for maximum quality (one observation per fact). Adjust `HINDSIGHT_API_CONSOLIDATION_BATCH_SIZE` to control DB memory usage during large consolidation jobs.

The Insight (Rule of Thumb)

  • Action: Set `HINDSIGHT_API_CONSOLIDATION_LLM_BATCH_SIZE=8` and `HINDSIGHT_API_CONSOLIDATION_BATCH_SIZE=50`.
  • Value: 8 facts per LLM call (default); 50 memories per DB batch.
  • Trade-off: Higher LLM batch size = fewer API calls, lower cost, faster — but each observation synthesizes more facts, potentially losing nuance. Lower = more focused observations but more LLM calls and higher cost.
  • Compatibility: Facts are grouped by tag group before sub-batching — the LLM batch respects tag boundaries. `llm_batch_size=1` disables batching entirely.

Reasoning

Consolidation is the most LLM-intensive operation in MemoMind — every memory that needs consolidation triggers at least one LLM call. With `llm_batch_size=8`, 8 facts are synthesized into observations in a single call, reducing API calls by 8x compared to batch_size=1. The tag-group-first ordering ensures that related facts (sharing tags) are synthesized together, producing more coherent observations. The DB batch size (50) controls how many memories are loaded into memory at once — too large causes memory pressure; too small causes excessive DB roundtrips.

Code Evidence

Batch size configuration from `config.py:461-462`:

DEFAULT_CONSOLIDATION_BATCH_SIZE = 50  # Memories to load per batch
DEFAULT_CONSOLIDATION_LLM_BATCH_SIZE = 8  # Facts per LLM call (1 = no batching; >1 = batch mode)

Batch sizing in consolidator from `consolidator.py:187-283`:

max_memories_per_batch = config.consolidation_batch_size
llm_batch_size = max(1, config.consolidation_llm_batch_size)
# ...
# Flatten into LLM batches respecting both tag groups and llm_batch_size
llm_batches = []
for group in tag_groups:
    for i in range(0, len(group), llm_batch_size):
        llm_batches.append(group[i : i + llm_batch_size])

Token budget per observation from `config.py:467-469`:

DEFAULT_CONSOLIDATION_SOURCE_FACTS_MAX_TOKENS_PER_OBSERVATION = 256  # Max tokens of source facts per observation

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment