MCPcopy Index your code
hub / github.com/codeaashu/claude-code / collectCandidatesFromMessage

Function collectCandidatesFromMessage

src/utils/toolResultStorage.ts:557–573  ·  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

555 * Returns [] for messages with no eligible blocks.
556 */
557function collectCandidatesFromMessage(message: Message): ToolResultCandidate[] {
558 if (message.type !== 'user' || !Array.isArray(message.message.content)) {
559 return []
560 }
561 return message.message.content.flatMap(block => {
562 if (block.type !== 'tool_result' || !block.content) return []
563 if (isContentAlreadyCompacted(block.content)) return []
564 if (hasImageBlock(block.content)) return []
565 return [
566 {
567 toolUseId: block.tool_use_id,
568 content: block.content,
569 size: contentSize(block.content),
570 },
571 ]
572 })
573}
574
575/**
576 * 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