Context
In PR #9964, we implemented a tail-end truncation mechanism (max 10,000 chars) for SessionService to prevent n_ctx token exhaustion crashes during local LLM summarization.
While this stabilizes the REM pipeline and prevents the daemon from crashing, it is mathematically lossy. By truncating the chronological head of the session, we lose critical context regarding the original problem statement, hypotheses, and initial exploratory commands, summarizing only the "resolution".
Required Architecture
To achieve 100% data preservation while remaining strictly within the n_ctx: 4096 local constraints, we must refactor SessionService.summarizeSession() to utilize a Map-Reduce pipeline:
- Map (Chunking): Slice the
memories.documents array into chronological batches that safely fit within a ~3000 token limit.
- Reduce (Sub-Summaries): Iterate over these batches, invoking the local AI provider to generate a sequential sub-summary.
- Compress: Feed the array of generated sub-summaries into a final compression prompt to generate the ultimate, all-encompassing
SessionSummary object without overflowing the context window.
Graph Links
- Blocks #9954 (Self-Healing Protocol) by ensuring historical accuracy.
- Conceptual successor to #9921.
Context
In PR #9964, we implemented a tail-end truncation mechanism (max 10,000 chars) for
SessionServiceto preventn_ctxtoken exhaustion crashes during local LLM summarization.While this stabilizes the REM pipeline and prevents the daemon from crashing, it is mathematically lossy. By truncating the chronological head of the session, we lose critical context regarding the original problem statement, hypotheses, and initial exploratory commands, summarizing only the "resolution".
Required Architecture
To achieve 100% data preservation while remaining strictly within the
n_ctx: 4096local constraints, we must refactorSessionService.summarizeSession()to utilize a Map-Reduce pipeline:memories.documentsarray into chronological batches that safely fit within a ~3000 token limit.SessionSummaryobject without overflowing the context window.Graph Links