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
This commit is contained in:
crsp6447
2026-04-27 22:53:14 +02:00
committed by GitHub
parent 338119ab77
commit 940b3722cf
+1 -1
View File
@@ -1040,7 +1040,7 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth, ttl)
text: content, text: content,
cache_control: { type: 'ephemeral', ttl: ttl }, cache_control: { type: 'ephemeral', ttl: ttl },
}]; }];
} else { } else if (content?.length > 0) {
const contentPartCount = content.length; const contentPartCount = content.length;
content[contentPartCount - 1].cache_control = { content[contentPartCount - 1].cache_control = {
type: 'ephemeral', type: 'ephemeral',