billion-context 0.1.103 → 0.1.104-pr.700.529
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -51956,7 +51956,11 @@ ${reasons.map((r) => `- ${r}`).join("\n")}` : "";
|
|
|
51956
51956
|
const shrinkRatio = preContext > 0 ? r.tokensCompressed / preContext : 0;
|
|
51957
51957
|
const foldPoint = [...ranges].sort((a, b2) => refNum(a.startRef) - refNum(b2.startRef))[0]?.startRef ?? "unknown";
|
|
51958
51958
|
ctx.session.lastCompress = { at: Date.now(), shrinkRatio, foldPoint, blocks: r.blocksCreated, tokensCompressed: r.tokensCompressed };
|
|
51959
|
-
ctx.
|
|
51959
|
+
ctx.session.stats.pendingFoldUsage = true;
|
|
51960
|
+
const anchorTok = res.state.blocks.reduce((n, b2) => n + (b2.active ? Math.ceil(b2.summary.length / 4) : 0), 0);
|
|
51961
|
+
const postCtx = Math.max(0, preContext - r.tokensCompressed);
|
|
51962
|
+
const ceiling = postCtx > 0 ? Math.floor(100 * anchorTok / postCtx) : 0;
|
|
51963
|
+
ctx.log(`[acp-compress-obs] shrink ${Math.round(shrinkRatio * 100)}% (~${r.tokensCompressed}/${preContext} tok) foldPoint=${foldPoint} blocks=${r.blocksCreated} anchor\u2248${anchorTok} tok (${res.state.blocks.filter((b2) => b2.active).length} active blocks, sys excluded) postCtx\u2248${postCtx} \u2192 next-request cache ceiling \u2265${ceiling}%`);
|
|
51960
51964
|
const warn = r.warnings.length > 0 ? ` ${r.warnings.join("; ")}` : "";
|
|
51961
51965
|
let msg = `[Compressed ${detail} \u2192 ${r.blocksCreated} block(s), ~${r.tokensCompressed} tokens saved.${warn}]`;
|
|
51962
51966
|
const maxShrink = maxShrinkPerCompress();
|
|
@@ -53490,8 +53494,10 @@ function recordUsage(ctx, usage, round) {
|
|
|
53490
53494
|
if (typeof out === "number") ctx.session.stats.outputTokens += out;
|
|
53491
53495
|
const hitPct = typeof cached === "number" && total > 0 ? Math.round(cached / total * 100) : 0;
|
|
53492
53496
|
warnCacheCollapse(ctx.session, total, cached ?? 0);
|
|
53497
|
+
const foldNew = ctx.session.stats.pendingFoldUsage === true;
|
|
53498
|
+
if (foldNew) ctx.session.stats.pendingFoldUsage = false;
|
|
53493
53499
|
ctx.log(
|
|
53494
|
-
`[acp-usage] round ${round} input=${total} cached=${cached ?? 0} (cache hit ${hitPct}%)`
|
|
53500
|
+
`[acp-usage] round ${round} input=${total} cached=${cached ?? 0} (cache hit ${hitPct}%)${foldNew ? " fold=new" : ""}`
|
|
53495
53501
|
);
|
|
53496
53502
|
}
|
|
53497
53503
|
async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adapter, systemPrompt, signal) {
|
|
@@ -56770,6 +56776,10 @@ function applyUsageSample(session, sample, protocol) {
|
|
|
56770
56776
|
session.stats.lastInputTokens = Math.max(0, total - (session.stats.compressCreditTokens ?? 0));
|
|
56771
56777
|
warnCacheCollapse(session, total, sample.cachedTokens ?? 0);
|
|
56772
56778
|
session.hostContextTokens = total + (session.hostCreditTokens ?? 0);
|
|
56779
|
+
const hit = sample.cachedTokens === void 0 || total <= 0 ? void 0 : Math.round(100 * (sample.cachedTokens ?? 0) / total);
|
|
56780
|
+
const foldNew = session.stats.pendingFoldUsage === true;
|
|
56781
|
+
if (foldNew) session.stats.pendingFoldUsage = false;
|
|
56782
|
+
log("info", `[${session.id}] [plugin] [acp-usage] input=${total} cached=${sample.cachedTokens ?? "n/a"}${hit === void 0 ? "" : ` (cache hit ${hit}%)`} ctx=${session.hostContextTokens}${foldNew ? " fold=new" : ""}`);
|
|
56773
56783
|
}
|
|
56774
56784
|
if (sample.outputTokens !== void 0) session.stats.outputTokens += sample.outputTokens;
|
|
56775
56785
|
}
|