MCPcopy Create free account
hub / github.com/Noumena-Network/code / getEffectiveContextWindowSize

Function getEffectiveContextWindowSize

src/services/compact/autoCompact.ts:36–57  ·  view source on GitHub ↗
(model: string)

Source from the content-addressed store, hash-verified

34// Managed models use separate input/output token budgets, so no output reserve
35// is subtracted from the prompt budget.
36export function getEffectiveContextWindowSize(model: string): number {
37 let contextWindow = getContextWindowForModel(model, getSdkBetas())
38
39 const autoCompactWindow = process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW
40 if (autoCompactWindow) {
41 const parsed = parseInt(autoCompactWindow, 10)
42 if (!isNaN(parsed) && parsed > 0) {
43 contextWindow = Math.min(contextWindow, parsed)
44 }
45 }
46
47 if (resolveNCodeManagedModel(model) !== undefined) {
48 return contextWindow
49 }
50
51 const reservedTokensForSummary = Math.min(
52 getMaxOutputTokensForModel(model),
53 MAX_OUTPUT_TOKENS_FOR_SUMMARY,
54 )
55
56 return contextWindow - reservedTokensForSummary
57}
58
59export type AutoCompactTrackingState = {
60 compacted: boolean

Callers 8

TokenWarningFunction · 0.85
getTokenUsageAttachmentFunction · 0.85
analyzeContextUsageFunction · 0.85
getAutoCompactThresholdFunction · 0.85
shouldAutoCompactFunction · 0.85

Calls 4

getContextWindowForModelFunction · 0.85
getSdkBetasFunction · 0.85
resolveNCodeManagedModelFunction · 0.85

Tested by

no test coverage detected