increase token buffer to 2048 for safer margin

This commit is contained in:
Russell Ballestrini 2025-07-11 15:15:23 -04:00
parent 96f8edc2e7
commit 3a4952087d

View file

@ -13,7 +13,7 @@ function estimateTokens(text) {
function calculateAvailableTokens(chatHistory, maxTokens) {
const inputText = chatHistory.map(msg => msg.content).join('');
const inputTokens = estimateTokens(inputText);
const availableTokens = Math.max(100, maxTokens - inputTokens - 50); // Reserve 50 tokens buffer
const availableTokens = Math.max(100, maxTokens - inputTokens - 2048); // Reserve 2048 tokens buffer
console.log(`Token calculation: max=${maxTokens}, input≈${inputTokens}, available≈${availableTokens}`);
return availableTokens;
}