Implementation:24kchengYe MemoMind build batch consolidation prompt
| Knowledge Sources | |
|---|---|
| Domains | LLM_Engineering, Prompt_Engineering |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Concrete tool for building the LLM prompt used in batch memory consolidation, with a customizable mission, processing rules, and structured output format.
Description
The build_batch_consolidation_prompt function constructs the prompt sent to the LLM during the consolidation batch call. The prompt has four sections:
- Mission: defines what to track (customizable per bank via observations_mission; defaults to "Track every detail: names, numbers, dates, places, and relationships")
- Processing rules: always present regardless of mission
- Language: write observations in the SAME language as source facts (never translate)
- Redundant: same info worded differently -> UPDATE existing observation
- Contradiction: capture both states with temporal markers ("used to X, now Y")
- Resolve references: when a new fact resolves a vague placeholder, update the observation
- Never merge observations about different people or unrelated topics
- Data section: format placeholders {facts_text} and {observations_text} substituted at call time
- Output format: JSON with creates/updates/deletes arrays, including examples of good vs. bad observation text
The prompt uses `.format()` with doubled braces ({{ }}) for literal JSON braces in the output format template.
Usage
Import this function when you need to build the consolidation LLM prompt. It is called by _consolidate_batch_with_llm for each batch of facts.
Code Reference
Source Location
- Repository: MemoMind
- File: engine/hindsight_api/engine/consolidation/prompts.py
- Lines: L70-84
Signature
def build_batch_consolidation_prompt(
observations_mission: str | None = None,
) -> str:
Import
from hindsight_api.engine.consolidation.prompts import build_batch_consolidation_prompt
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| observations_mission | str | No | Bank-specific mission defining what to track (defaults to "Track every detail...") |
Outputs
| Name | Type | Description |
|---|---|---|
| prompt | str | Prompt template with {facts_text} and {observations_text} placeholders |
Usage Examples
Building and Formatting a Consolidation Prompt
from hindsight_api.engine.consolidation.prompts import build_batch_consolidation_prompt
# Build the prompt template
prompt_template = build_batch_consolidation_prompt(
observations_mission="Track user health metrics: sleep, exercise, diet, mood"
)
# Format with actual data
prompt = prompt_template.format(
facts_text="[abc123] Alice ran 5km this morning\n[def456] Alice slept 8 hours",
observations_text='[{"id": "obs1", "text": "Alice exercises regularly", "proof_count": 3}]',
)
# Send to LLM
response = await llm_config.call(
messages=[{"role": "user", "content": prompt}],
response_format=ConsolidationBatchResponse,
)