feat: unify context compaction

This commit is contained in:
云服务部-叶林立
2026-09-01 14:52:43 +08:00
parent 44f27f7585
commit a4807dde67
114 changed files with 2681 additions and 21336 deletions
+10
View File
@@ -893,6 +893,16 @@ export default function (pi: ExtensionAPI) {
const contextWindow = model?.contextWindow ?? 0;
if (contextWindow === 0) return { percentage: 0, used: 0, total: 0 };
const effective = (globalThis as any)[Symbol.for("my-pi.pi-compaction.service.v1")]
?.getMetrics(ctx.sessionManager.getSessionId());
if (effective) {
return {
percentage: effective.percent,
used: effective.effectiveTokens,
total: effective.contextWindow || contextWindow,
};
}
const entries = ctx.sessionManager.getEntries();
const leafId = ctx.sessionManager.getLeafId();
const context = buildSessionContext(entries, leafId);