earendil-works/pi · error · TypeError

Tool result ${message.toolName} does not match tool call ${c

Error message

Tool result ${message.toolName} does not match tool call ${callName}

What it means

Error "Tool result ${message.toolName} does not match tool call ${callName}" thrown in earendil-works/pi.

Source

Thrown at packages/server/src/protocol.ts:364

			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.isError
		? ({ ...common, status: "error", isError: true } satisfies ToolTranscriptItem)
		: ({ ...common, status: "complete", isError: false } satisfies ToolTranscriptItem);
}

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Send tool results whose toolName matches the originating tool call.

When it happens

Trigger: Thrown at packages/server/src/protocol.ts:364 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/7f04eeeffe521fb4. Report an issue: GitHub.