Skip to content

Commit 0666cbd

Browse files
committed
fix: the reservedForOutput variable should be 20 percent if max tokens and context window are equal
1 parent 725b617 commit 0666cbd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

webview-ui/src/utils/model-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export const calculateTokenDistribution = (
100100

101101
// Get the actual max tokens value from the model
102102
// If maxTokens is valid, use it, otherwise reserve 20% of the context window as a default
103-
const reservedForOutput = maxTokens && maxTokens > 0 ? maxTokens : Math.ceil(safeContextWindow * 0.2)
103+
const defaultReserved = Math.ceil(safeContextWindow * 0.2)
104+
const reservedForOutput = maxTokens && maxTokens > 0 && maxTokens < defaultReserved ? maxTokens : defaultReserved
104105

105106
// Calculate sizes directly without buffer display
106107
const availableSize = Math.max(0, safeContextWindow - safeContextTokens - reservedForOutput)

0 commit comments

Comments
 (0)