{"record":{"id":"417e5247f0b0155e","repo":"earendil-works/pi","slug":"tool-result-message-toolcallid-does-not-match-t","errorCode":null,"errorMessage":"Tool result ${message.toolCallId} does not match tool call ${callId}","messagePattern":"Tool result (.+?) does not match tool call (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/server/src/protocol.ts","lineNumber":361,"sourceCode":"\t\t\t\treturn { type: \"text\", text: part.text };\n\t\t\tcase \"image\":\n\t\t\t\treturn { type: \"image\", data: part.data, mimeType: part.mimeType };\n\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","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/server/src/protocol.ts#L343-L379","documentation":"Error \"Tool result ${message.toolCallId} does not match tool call ${callId}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/server/src/protocol.ts:361 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send tool results with the toolCallId of 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"}