Adjust context management buffer

This commit is contained in:
Saoud Rizwan
2024-08-30 09:51:14 -04:00
parent 92722abcba
commit dcd6d84632
2 changed files with 2 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
"name": "claude-dev", "name": "claude-dev",
"displayName": "Claude Dev", "displayName": "Claude Dev",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.", "description": "Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.",
"version": "1.5.2", "version": "1.5.3",
"icon": "icon.png", "icon": "icon.png",
"engines": { "engines": {
"vscode": "^1.84.0" "vscode": "^1.84.0"

View File

@@ -9,7 +9,7 @@ export function isWithinContextWindow(
tools: Anthropic.Messages.Tool[], tools: Anthropic.Messages.Tool[],
messages: Anthropic.Messages.MessageParam[] messages: Anthropic.Messages.MessageParam[]
): boolean { ): boolean {
const adjustedContextWindow = contextWindow - 10_000 // Buffer to account for tokenizer differences const adjustedContextWindow = contextWindow * 0.75 // Buffer to account for tokenizer differences
// counting tokens is expensive, so we first try to estimate before doing a more accurate calculation // counting tokens is expensive, so we first try to estimate before doing a more accurate calculation
const estimatedTotalMessageTokens = countTokens(systemPrompt + JSON.stringify(tools) + JSON.stringify(messages)) const estimatedTotalMessageTokens = countTokens(systemPrompt + JSON.stringify(tools) + JSON.stringify(messages))
if (estimatedTotalMessageTokens <= adjustedContextWindow) { if (estimatedTotalMessageTokens <= adjustedContextWindow) {