MCPcopy Index your code
hub / github.com/continuedev/continue / countToolDefinitionTokens

Function countToolDefinitionTokens

extensions/cli/src/util/tokenizer.ts:281–295  ·  view source on GitHub ↗
(tools: ChatCompletionTool[])

Source from the content-addressed store, hash-verified

279 * @returns Estimated token count for all tool definitions
280 */
281export function countToolDefinitionTokens(tools: ChatCompletionTool[]): number {
282 if (!tools || tools.length === 0) {
283 return 0;
284 }
285
286 // Base overhead for the tools array structure
287 let numTokens = 12;
288
289 for (const tool of tools) {
290 numTokens += countSingleToolTokens(tool);
291 }
292
293 // Additional overhead for the tools wrapper
294 return numTokens + 12;
295}
296
297/**
298 * Parameters for calculating total input tokens including all components

Callers 3

shouldAutoCompactFunction · 0.85
countTotalInputTokensFunction · 0.85
tokenizer.test.tsFile · 0.85

Calls 1

countSingleToolTokensFunction · 0.85

Tested by

no test coverage detected