mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat: unify context compaction
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user