MCPcopy Create free account
hub / github.com/continuedev/continue / calculateThreshold

Function calculateThreshold

extensions/cli/src/util/tokenizer.test.ts:256–269  ·  view source on GitHub ↗
(
      contextLength: number,
      maxTokens: number,
    )

Source from the content-addressed store, hash-verified

254
255 // Helper to calculate threshold using the new formula
256 const calculateThreshold = (
257 contextLength: number,
258 maxTokens: number,
259 ): number => {
260 const ratioCompactionBuffer = Math.ceil(
261 (1 - AUTO_COMPACT_BUFFER_RATIO) * (contextLength - maxTokens),
262 );
263 const safeCompactionBuffer = Math.max(maxTokens, ratioCompactionBuffer);
264 const compactionBuffer = Math.min(
265 safeCompactionBuffer,
266 AUTO_COMPACT_BUFFER_CAP,
267 );
268 return contextLength - maxTokens - compactionBuffer;
269 };
270
271 it("should compact when input tokens exceed threshold with maxTokens", () => {
272 const model = createModel(1000, 200); // 1000 context, 200 max output

Callers 1

tokenizer.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected