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

Function countToolCallFunctionTokens

extensions/cli/src/util/tokenizer.ts:67–78  ·  view source on GitHub ↗

* Count tokens in a single tool call function

(
  toolCallFunction: { name?: string; arguments?: string } | undefined,
)

Source from the content-addressed store, hash-verified

65 * Count tokens in a single tool call function
66 */
67function countToolCallFunctionTokens(
68 toolCallFunction: { name?: string; arguments?: string } | undefined,
69): number {
70 if (!toolCallFunction) {
71 return 0;
72 }
73
74 let tokenCount = 0;
75 tokenCount += encode(toolCallFunction.name ?? "").length + 10; // Function name and structure overhead
76 tokenCount += encode(toolCallFunction.arguments ?? "").length; // Arguments
77 return tokenCount;
78}
79
80/**
81 * Count tokens in tool call outputs

Callers 1

Calls 1

encodeFunction · 0.50

Tested by

no test coverage detected