earendil-works/pi · error · TypeError
Tool result ${message.toolCallId} does not match tool call $
Error message
Tool result ${message.toolCallId} does not match tool call ${callId} What it means
Error "Tool result ${message.toolCallId} does not match tool call ${callId}" thrown in earendil-works/pi.
Source
Thrown at packages/server/src/protocol.ts:361
return { type: "text", text: part.text };
case "image":
return { type: "image", data: part.data, mimeType: part.mimeType };
default: {
const exhaustive: never = part;
return exhaustive;
}
}
});
}
export function toProtocolToolResultMessage(
message: ToolResultMessage,
options: ToolTranscriptOptions,
): ToolTranscriptItem {
const callId = identifier(options.call.id, "Tool call id");
const callName = identifier(options.call.name, "Tool call name");
if (identifier(message.toolCallId, "Tool result call id") !== callId) {
throw new TypeError(`Tool result ${message.toolCallId} does not match tool call ${callId}`);
}
if (identifier(message.toolName, "Tool result name") !== callName) {
throw new TypeError(`Tool result ${message.toolName} does not match tool call ${callName}`);
}
const details = sanitizeProtocolDetails(message.details);
const usage = toProtocolUsage(message.usage);
const common = {
id: identifier(options.id, "Transcript item id"),
role: "tool",
toolCallId: callId,
toolName: callName,
input: toProtocolJsonValue(options.call.arguments),
content: toProtocolToolContent(message.content),
...(details === undefined ? {} : { details }),
...(usage ? { usage } : {}),
timestamp: timestamp(message.timestamp),
} as const;
return message.isErrorView on GitHub (pinned to 4af9d21d3b)
Solutions
- Send tool results with the toolCallId of the originating tool call.
When it happens
Trigger: Thrown at packages/server/src/protocol.ts:361 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/417e5247f0b0155e.
Report an issue: GitHub.