From 5c2733075470e8a325bb89f5ba9bf61d67c85215 Mon Sep 17 00:00:00 2001 From: Ciaran Morinan Date: Mon, 16 Dec 2024 13:03:31 +0000 Subject: [PATCH] catch new block.content string response type --- .../src/activities/shared/get-llm-response/llm-message.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/llm-message.ts b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/llm-message.ts index 2289dbb7bb4..f09f2df7fff 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/llm-message.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/get-llm-response/llm-message.ts @@ -110,6 +110,12 @@ export const mapAnthropicMessageToLlmMessage = (params: { } else if (block.type === "tool_use") { throw new Error("Tool use content not supported"); } else if (block.type === "tool_result") { + if (typeof block.content === "string") { + throw new Error( + "Unexpected string content for tool result, expected object with type field", + ); + } + /** * Currently images are not supported in LLM messages, * so we filter them out from the content.