MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / estimateTokenCount

Function estimateTokenCount

src/core/context-management/index.ts:35–41  ·  view source on GitHub ↗
(
	content: Array<Anthropic.Messages.ContentBlockParam>,
	apiHandler: ApiHandler,
)

Source from the content-addressed store, hash-verified

33 * @returns {Promise<number>} A promise resolving to the token count
34 */
35export async function estimateTokenCount(
36 content: Array<Anthropic.Messages.ContentBlockParam>,
37 apiHandler: ApiHandler,
38): Promise<number> {
39 if (!content || content.length === 0) return 0
40 return apiHandler.countTokens(content)
41}
42
43/**
44 * Computes the percentage of the context budget consumed by the prior context.

Callers 2

manageContextFunction · 0.70

Calls 1

countTokensMethod · 0.65

Tested by

no test coverage detected