MCPcopy
hub / github.com/codeaashu/claude-code / getEffectiveContextWindowSize

Function getEffectiveContextWindowSize

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

Source from the content-addressed store, hash-verified

31
32// Returns the context window size minus the max output tokens for the model
33export function getEffectiveContextWindowSize(model: string): number {
34 const reservedTokensForSummary = Math.min(
35 getMaxOutputTokensForModel(model),
36 MAX_OUTPUT_TOKENS_FOR_SUMMARY,
37 )
38 let contextWindow = getContextWindowForModel(model, getSdkBetas())
39
40 const autoCompactWindow = process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW
41 if (autoCompactWindow) {
42 const parsed = parseInt(autoCompactWindow, 10)
43 if (!isNaN(parsed) && parsed > 0) {
44 contextWindow = Math.min(contextWindow, parsed)
45 }
46 }
47
48 return contextWindow - reservedTokensForSummary
49}
50
51export type AutoCompactTrackingState = {
52 compacted: boolean

Callers 7

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

Calls 3

getContextWindowForModelFunction · 0.85
getSdkBetasFunction · 0.85

Tested by

no test coverage detected