{"record":{"id":"7f04eeeffe521fb4","repo":"earendil-works/pi","slug":"tool-result-message-toolname-does-not-match-too","errorCode":null,"errorMessage":"Tool result ${message.toolName} does not match tool call ${callName}","messagePattern":"Tool result (.+?) does not match tool call (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/server/src/protocol.ts","lineNumber":364,"sourceCode":"\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = part;\n\t\t\t\treturn exhaustive;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport function toProtocolToolResultMessage(\n\tmessage: ToolResultMessage,\n\toptions: ToolTranscriptOptions,\n): ToolTranscriptItem {\n\tconst callId = identifier(options.call.id, \"Tool call id\");\n\tconst callName = identifier(options.call.name, \"Tool call name\");\n\tif (identifier(message.toolCallId, \"Tool result call id\") !== callId) {\n\t\tthrow new TypeError(`Tool result ${message.toolCallId} does not match tool call ${callId}`);\n\t}\n\tif (identifier(message.toolName, \"Tool result name\") !== callName) {\n\t\tthrow new TypeError(`Tool result ${message.toolName} does not match tool call ${callName}`);\n\t}\n\tconst details = sanitizeProtocolDetails(message.details);\n\tconst usage = toProtocolUsage(message.usage);\n\tconst common = {\n\t\tid: identifier(options.id, \"Transcript item id\"),\n\t\trole: \"tool\",\n\t\ttoolCallId: callId,\n\t\ttoolName: callName,\n\t\tinput: toProtocolJsonValue(options.call.arguments),\n\t\tcontent: toProtocolToolContent(message.content),\n\t\t...(details === undefined ? {} : { details }),\n\t\t...(usage ? { usage } : {}),\n\t\ttimestamp: timestamp(message.timestamp),\n\t} as const;\n\treturn message.isError\n\t\t? ({ ...common, status: \"error\", isError: true } satisfies ToolTranscriptItem)\n\t\t: ({ ...common, status: \"complete\", isError: false } satisfies ToolTranscriptItem);\n}","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/server/src/protocol.ts#L346-L382","documentation":"Error \"Tool result ${message.toolName} does not match tool call ${callName}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/server/src/protocol.ts:364 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send tool results whose toolName matches the originating tool call."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}