backend/docs/MEMORY_IMPROVEMENTS.md
This document tracks memory injection behavior and roadmap status.
Implemented in main:
tiktoken in format_memory_for_injection.max_injection_tokens budget.Planned / not yet merged:
current_context input for context-aware scoring.similarity_weight, confidence_weight).Function today:
def format_memory_for_injection(memory_data: dict[str, Any], max_tokens: int = 2000) -> str:
Current injection format:
User Context section from user.*.summaryHistory section from history.*.summaryFacts section from facts[], sorted by confidence, appended until token budget is reachedToken counting:
tiktoken (cl100k_base) when availablelen(text) // 4 if tokenizer import failsPrevious versions of this document described TF-IDF/context-aware retrieval as if it were already shipped.
That was not accurate for main and caused confusion.
Issue reference: #1059
Planned scoring strategy:
final_score = (similarity * 0.6) + (confidence * 0.4)
Planned integration shape:
Current regression coverage includes:
Tests:
backend/tests/test_memory_prompt_injection.py