MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / prefixChars

Function prefixChars

src/llm/cache-layout.ts:53–59  ·  view source on GitHub ↗
(messages: Message[], n: number)

Source from the content-addressed store, hash-verified

51
52/** Approximate character count of the first `n` messages (proxy for cached tokens). */
53export function prefixChars(messages: Message[], n: number): number {
54 let chars = 0;
55 for (let i = 0; i < Math.min(n, messages.length); i++) {
56 chars += serializeMessage(messages[i]!).length;
57 }
58 return chars;
59}
60
61export interface CacheReuse {
62 /** Leading messages shared with the previous turn. */

Callers 2

describeCacheReuseFunction · 0.85

Calls 1

serializeMessageFunction · 0.85

Tested by

no test coverage detected