From 99f28a2dff67002585f90c53fb9bf1508bbe5556 Mon Sep 17 00:00:00 2001 From: serhiy-matoffo Date: Wed, 6 Nov 2024 18:30:45 +0200 Subject: [PATCH] Update commonUtils.ts (#3470) Fixed a bug in `restructureMessages` leading to blowing up of the message content with escape characters and eventually crashing the flow with "repetitive patterns" error --- packages/components/nodes/sequentialagents/commonUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/sequentialagents/commonUtils.ts b/packages/components/nodes/sequentialagents/commonUtils.ts index 9d3ac8669..c2c2505a5 100644 --- a/packages/components/nodes/sequentialagents/commonUtils.ts +++ b/packages/components/nodes/sequentialagents/commonUtils.ts @@ -212,7 +212,7 @@ export const restructureMessages = (llm: BaseChatModel, state: ISeqAgentsState) const messages: BaseMessage[] = [] for (const message of state.messages as unknown as BaseMessage[]) { // Sometimes Anthropic can return a message with content types of array, ignore that EXECEPT when tool calls are present - if ((message as any).tool_calls?.length) { + if ((message as any).tool_calls?.length && message.content !== '') { message.content = JSON.stringify(message.content) }