MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / countTokens

Function countTokens

lib/token-utils.ts:69–76  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

67}
68
69export function countTokens(text: string): number {
70 if (!text) return 0
71 try {
72 return anthropicCountTokens(text)
73 } catch {
74 return Math.round(text.length / 4)
75 }
76}
77
78export function estimateTokensBatch(texts: string[]): number {
79 if (texts.length === 0) return 0

Callers 6

analyzeContextTokensFunction · 0.90
loadPruneMessagesStateFunction · 0.90
cacheSystemPromptTokensFunction · 0.90
executeFunction · 0.90
executeFunction · 0.90
estimateTokensBatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected