MCPcopy Create free account
hub / github.com/Noumena-Network/code / contentSize

Function contentSize

src/utils/toolResultStorage.ts:537–548  ·  view source on GitHub ↗
(
  content: NonNullable<ToolResultBlockParam['content']>,
)

Source from the content-addressed store, hash-verified

535}
536
537function contentSize(
538 content: NonNullable<ToolResultBlockParam['content']>,
539): number {
540 if (typeof content === 'string') return content.length
541 // Sum text-block lengths directly. Slightly under-counts vs serialized
542 // (no JSON framing), but the budget is a rough token heuristic anyway.
543 // Avoids allocating a content-sized string every enforcement pass.
544 return content.reduce(
545 (sum, b) => sum + (b.type === 'text' ? b.text.length : 0),
546 0,
547 )
548}
549
550/**
551 * Walk messages and build tool_use_id → tool_name from assistant tool_use

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected