You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- session.error: remove session.summarize() call on overflow — it sent all
messages to the model causing the overflow→compact→overflow stuck loop.
Now just distills + sets forceMinLayer(2); gradient layers 2-4 handle
compression on the next turn.
- compacting hook: run chunked distillation first, inject pre-computed
summaries into output.context, instruct model to consolidate summaries
rather than re-reading raw messages. Prevents overflow during /compact
on large sessions.
- distillation.loadForSession(): new export to read back distillation rows
without going through gradient internals.
- session.error: broaden error detection to match both error.data.message
and error.message shapes; add more overflow message patterns; add
diagnostic logging to see the actual error shape in stderr.
Copy file name to clipboardExpand all lines: src/distillation.ts
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,32 @@ export type Distillation = {
117
117
created_at: number;
118
118
};
119
119
120
+
/** Load all distillations for a session, oldest first. */
121
+
exportfunctionloadForSession(
122
+
projectPath: string,
123
+
sessionID: string,
124
+
): Distillation[]{
125
+
constpid=ensureProject(projectPath);
126
+
constrows=db()
127
+
.query(
128
+
"SELECT id, project_id, session_id, observations, source_ids, generation, token_count, created_at FROM distillations WHERE project_id = ? AND session_id = ? ORDER BY created_at ASC",
// Inject each distillation chunk as a context string so the model has access
445
+
// to pre-computed summaries. Even if the raw messages overflow context, these
446
+
// summaries are compact and will fit.
447
+
if(distillations.length>0){
448
+
output.context.push(
449
+
`## Lore Pre-computed Session Summaries\n\nThe following ${distillations.length} summary chunk(s) were pre-computed from the conversation history. Use these as the authoritative source — do not re-summarize the raw messages above if they conflict.\n\n`+
output.prompt=`You are creating a distilled memory summary for an AI coding agent. This summary will be the ONLY context available in the next part of the conversation.
436
460
437
-
Structure your response as follows:
461
+
${distillations.length>0 ? "Lore has pre-computed chunked summaries of the session history (injected above as context). Consolidate those summaries into a single coherent narrative. Do NOT re-read or re-summarize the raw conversation messages — trust the pre-computed summaries.\n\n" : ""}Structure your response as follows:
0 commit comments