fix pre-step cancellation and compaction convergence

This commit is contained in:
Hypatia May
2026-06-30 10:56:34 +08:00
parent 6ae1e229fd
commit b0eae94fc8
5 changed files with 63 additions and 15 deletions
+5 -4
View File
@@ -455,10 +455,11 @@ export class BasicCompactService extends CompactService {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
shadowedTokenCount += this.estimateEventTokens(session.events[seq]!)
}
const summaryTokenCount = this.estimateContentTokens(summary)
if (summaryTokenCount >= shadowedTokenCount) {
const framedSummary = this._frameSummary(summary)
const framedSummaryTokenCount = this.estimateContentTokens(framedSummary)
if (framedSummaryTokenCount >= shadowedTokenCount) {
throw new Error(
`summary is not smaller than the shadowed content (${summaryTokenCount} estimated tokens >= ${shadowedTokenCount})`,
`summary is not smaller than the shadowed content (${framedSummaryTokenCount} estimated framed tokens >= ${shadowedTokenCount})`,
)
}
// --- Provenance record (log-only) ---
@@ -477,7 +478,7 @@ export class BasicCompactService extends CompactService {
// The landed content is FRAMED (checkpoint preamble + tag-wrapped summary);
// the compact/summary provenance event above holds the raw model output.
session.append('user/message', {
content: this._frameSummary(summary),
content: framedSummary,
source: { kind: 'plugin', plugin: 'compact' },
}, {
surfaceOp: { op: 'replace', start, end },