LearnNewsExamplesServices
Frontmatter
id9942
titlebug(ai): Resolve local inference 4096 n_ctx Exhaustion During Session Summarization
stateClosed
labels
bugaicore
assigneestobiu
createdAtApr 12, 2026, 9:31 PM
updatedAtApr 12, 2026, 11:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/9942
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 12, 2026, 10:36 PM

bug(ai): Resolve local inference 4096 n_ctx Exhaustion During Session Summarization

tobiu
tobiu commented on Apr 12, 2026, 9:31 PM

Context

When the Memory service attempts to summarize a massive session (e.g., ones with over 50-100 interactions), it joins all memory documents into a single aggregatedContent payload. For Local LLMs running with a default n_ctx limit of 4096, this payload throws an Out-Of-Memory / context length exceeded error. Because the loop executing the batch in SessionService.summarizeSessions() lacks granular try/catch protection for individual session iterations, a single context length violation permanently halts the entire digestion daemon. This is why the session collection currently has 0 records after the vector DB engine swap.

Objectives

  1. Implement a safe truncation envelope (MAX_PAYLOAD_LENGTH) inside SessionService.summarizeSession(), slicing the middle out of oversized sessions to preserve original prompt context and final outcomes.
  2. Wrap the LLM generateContent block inside an internal try/catch within the batch iterator, ensuring that if a session summary fails, it isolates the failure and allows processUndigestedSessions to continue processing the remaining batches.
tobiu added the bug label on Apr 12, 2026, 9:31 PM
tobiu added the ai label on Apr 12, 2026, 9:31 PM
tobiu added the core label on Apr 12, 2026, 9:31 PM
tobiu cross-referenced by PR #9943 on Apr 12, 2026, 10:14 PM
tobiu referenced in commit b0cb622 - "fix(memory-core): Enforce explicit DreamService system prompt and token boundaries to resolve local inference context exhaustion (#9942)" on Apr 12, 2026, 10:36 PM
tobiu cross-referenced by PR #9944 on Apr 12, 2026, 10:36 PM
tobiu referenced in commit d1e89a9 - "fix(memory-core): Enforce explicit DreamService system prompt and token boundaries to resolve local inference context exhaustion (#9942) (#9944)" on Apr 12, 2026, 10:36 PM
tobiu closed this issue on Apr 12, 2026, 10:36 PM
tobiu assigned to @tobiu on Apr 12, 2026, 11:39 PM
tobiu referenced in commit 63afd01 - "feat(ai): primary-flag gate for session summarization (#10813) (#10817) on May 6, 2026, 3:06 PM