MCPcopy Create free account
hub / github.com/IIIIQIIII/claude-code / contentSize

Function contentSize

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

Source from the content-addressed store, hash-verified

516}
517
518function contentSize(
519 content: NonNullable<ToolResultBlockParam['content']>,
520): number {
521 if (typeof content === 'string') return content.length
522 // Sum text-block lengths directly. Slightly under-counts vs serialized
523 // (no JSON framing), but the budget is a rough token heuristic anyway.
524 // Avoids allocating a content-sized string every enforcement pass.
525 return content.reduce(
526 (sum, b) => sum + (b.type === 'text' ? b.text.length : 0),
527 0,
528 )
529}
530
531/**
532 * 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