Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/services/compact/autoCompact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,14 @@ export function calculateTokenWarningState(
? autoCompactThreshold
: getEffectiveContextWindowSize(model)

// Use the raw context window (without output reservation) for the percentage
// display, so users see remaining context relative to the model's full capacity.
// The threshold (which subtracts buffer) should only affect when we warn/compact,
// not what percentage we display.
const rawContextWindow = getContextWindowForModel(model, getSdkBetas())
const percentLeft = Math.max(
0,
Math.round(((threshold - tokenUsage) / threshold) * 100),
Math.round(((rawContextWindow - tokenUsage) / rawContextWindow) * 100),
)

const warningThreshold = threshold - WARNING_THRESHOLD_BUFFER_TOKENS
Expand Down
Loading