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

Function buildToolNameMap

src/utils/toolResultStorage.ts:555–568  ·  view source on GitHub ↗

* Walk messages and build tool_use_id → tool_name from assistant tool_use * blocks. tool_use always precedes its tool_result (model calls, then result * arrives), so by the time budget enforcement sees a result, its name is known.

(messages: Message[])

Source from the content-addressed store, hash-verified

553 * arrives), so by the time budget enforcement sees a result, its name is known.
554 */
555function buildToolNameMap(messages: Message[]): Map<string, string> {
556 const map = new Map<string, string>()
557 for (const message of messages) {
558 if (message.type !== 'assistant') continue
559 const content = message.message.content
560 if (!Array.isArray(content)) continue
561 for (const block of content) {
562 if (block.type === 'tool_use') {
563 map.set(block.id, block.name)
564 }
565 }
566 }
567 return map
568}
569
570/**
571 * Extract candidate tool_result blocks from a single user message: blocks

Callers 1

enforceToolResultBudgetFunction · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected