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

Function collectCandidatesFromMessage

src/utils/toolResultStorage.ts:576–592  ·  view source on GitHub ↗

* Extract candidate tool_result blocks from a single user message: blocks * that are non-empty, non-image, and not already compacted by tag (i.e. by * the per-tool limit, or an earlier iteration of this same query call). * Returns [] for messages with no eligible blocks.

(message: Message)

Source from the content-addressed store, hash-verified

574 * Returns [] for messages with no eligible blocks.
575 */
576function collectCandidatesFromMessage(message: Message): ToolResultCandidate[] {
577 if (message.type !== 'user' || !Array.isArray(message.message.content)) {
578 return []
579 }
580 return message.message.content.flatMap(block => {
581 if (block.type !== 'tool_result' || !block.content) return []
582 if (isContentAlreadyCompacted(block.content)) return []
583 if (hasImageBlock(block.content)) return []
584 return [
585 {
586 toolUseId: block.tool_use_id,
587 content: block.content,
588 size: contentSize(block.content),
589 },
590 ]
591 })
592}
593
594/**
595 * Extract candidate tool_result blocks grouped by API-level user message.

Callers 1

Calls 3

hasImageBlockFunction · 0.85
contentSizeFunction · 0.85

Tested by

no test coverage detected