From 940b3722cf80d3b4dd0855c5b70c167311299b28 Mon Sep 17 00:00:00 2001 From: crsp6447 Date: Mon, 27 Apr 2026 22:53:14 +0200 Subject: [PATCH] Fix: Prevent crash in cachingAtDepthForOpenRouterClaude on empty content from trailing tool calls (#5541) * Prevent crash in cachingAtDepthForOpenRouterClaude when message has no text * Apply optional chaining suggestion --- src/prompt-converters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prompt-converters.js b/src/prompt-converters.js index f033c8462..34ae3b388 100644 --- a/src/prompt-converters.js +++ b/src/prompt-converters.js @@ -1040,7 +1040,7 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth, ttl) text: content, cache_control: { type: 'ephemeral', ttl: ttl }, }]; - } else { + } else if (content?.length > 0) { const contentPartCount = content.length; content[contentPartCount - 1].cache_control = { type: 'ephemeral',