MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / estimateContentTokens

Function estimateContentTokens

apps/vis/server/src/lib/context-projector.ts:652–659  ·  view source on GitHub ↗
(content: readonly ContentPart[])

Source from the content-addressed store, hash-verified

650}
651
652function estimateContentTokens(content: readonly ContentPart[]): number {
653 let total = 0;
654 for (const p of content) {
655 if (p.type === 'text') total += estimateTokens(p.text);
656 else if (p.type === 'think') total += estimateTokens(p.think);
657 }
658 return total;
659}
660
661/** True for messages that correspond to a real agent-core `_history` entry —
662 * i.e. `append_message` and `compaction_summary` (the summary IS in `_history`).

Callers 1

projectContextFunction · 0.85

Calls 1

estimateTokensFunction · 0.70

Tested by

no test coverage detected