fix(sleeptime): trigger compaction reflection for legacy summary format (#1090)

This commit is contained in:
Charles Packer
2026-02-21 14:30:27 -08:00
committed by GitHub
parent 5d8a832c00
commit f5cc69c9d1
2 changed files with 35 additions and 5 deletions

View File

@@ -451,6 +451,13 @@ function extractTextPart(v: unknown): string {
return "";
}
function markCompactionCompleted(ctx?: ContextTracker): void {
if (!ctx) return;
ctx.pendingCompaction = true;
ctx.pendingSkillsReinject = true;
ctx.pendingReflectionTrigger = true;
}
function resolveLineIdForKind(
b: Buffers,
canonicalId: string,
@@ -787,6 +794,9 @@ export function onChunk(
phase: "finished",
summary: compactionSummary,
}));
// Legacy servers may emit compaction completion as a user_message
// system alert instead of summary_message.
markCompactionCompleted(ctx);
}
// If not a summary, ignore it (user messages aren't rendered during streaming)
break;
@@ -1131,11 +1141,7 @@ export function onChunk(
// Set here (not in event_message) because summary_message arrives after
// compaction completes, guaranteeing the next usage_statistics has the
// reduced token count.
if (ctx) {
ctx.pendingCompaction = true;
ctx.pendingSkillsReinject = true;
ctx.pendingReflectionTrigger = true;
}
markCompactionCompleted(ctx);
break;
}