MCPcopy Create free account
hub / github.com/codeaashu/claude-code / hoistToolResults

Function hoistToolResults

src/utils/messages.ts:2470–2483  ·  view source on GitHub ↗

* In thecontent[] list on a UserMessage, tool_result blocks much come first * to avoid "tool result must follow tool use" API errors.

(content: ContentBlockParam[])

Source from the content-addressed store, hash-verified

2468 * to avoid "tool result must follow tool use" API errors.
2469 */
2470function hoistToolResults(content: ContentBlockParam[]): ContentBlockParam[] {
2471 const toolResults: ContentBlockParam[] = []
2472 const otherBlocks: ContentBlockParam[] = []
2473
2474 for (const block of content) {
2475 if (block.type === 'tool_result') {
2476 toolResults.push(block)
2477 } else {
2478 otherBlocks.push(block)
2479 }
2480 }
2481
2482 return [...toolResults, ...otherBlocks]
2483}
2484
2485function normalizeUserTextContent(
2486 a: string | ContentBlockParam[],

Callers 2

mergeUserMessagesFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected