MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / getContextRatio

Function getContextRatio

apps/extension/src/shared/context-usage.ts:9–18  ·  view source on GitHub ↗
(
  promptTokens: number,
  contextLength: number | undefined
)

Source from the content-addressed store, hash-verified

7const clamp01 = (value: number): number => Math.min(1, Math.max(0, value));
8
9export const getContextRatio = (
10 promptTokens: number,
11 contextLength: number | undefined
12): number | undefined => {
13 if (contextLength === undefined || contextLength <= 0) {
14 return undefined;
15 }
16
17 return clamp01(promptTokens / contextLength);
18};
19
20export const getContextTone = (ratio: number): 'danger' | 'safe' | 'warn' => {
21 if (ratio >= 0.9) {

Callers 3

submitMessageFunction · 0.90
ContextDonutFunction · 0.90

Calls 1

clamp01Function · 0.70

Tested by

no test coverage detected