fix(compact): harden summarization convergence

Use maxTokens as the provider generation cap and remove the confusing stored-summary max config.

Strip reasoning blocks before storing compaction summaries, reject non-shrinking summaries, and retry bounded re-compaction when the surface remains over threshold.

Add config validation for numeric and type-shaped knobs plus unit and real-API e2e coverage for reasoning-capable summarization.
This commit is contained in:
Hypatia May
2026-06-29 16:56:44 +08:00
parent 1f35a4446d
commit 1808570933
8 changed files with 319 additions and 149 deletions

View File

@@ -91,14 +91,12 @@ async function harness(toolSteps: number): Promise<{ ctx: Context; compact: Repr
},
}))
// Tiny window so a couple of tool steps cross the threshold and compaction
// fires within the runaway turn. Convergence invariant holds:
// summarizationMaxTokens(1) + retainTokens(20) = 21 <= floor(60*0.5) = 30.
// fires within the runaway turn.
const compact = new ReproCompactService(ctx, {
auto: true,
contextWindow: 60,
contextWindow: 64,
thresholdRatio: 0.5,
retainTokens: 20,
summarizationMaxTokens: 1,
})
return { ctx, compact }
}