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

940b3722cf80d3b4dd0855c5b70c167311299b28

crsp6447 <crsp6447@pm.me>

Signed
1 files changed, +1 -1Showing whitespace changes
src/prompt-converters.js+1 -1
@@ -1040,7 +1040,7 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth, ttl)
10401040 text: content,
10411041 cache_control: { type: 'ephemeral', ttl: ttl },
10421042 }];
1043- } else {
1043+ } else if (content?.length > 0) {
10441044 const contentPartCount = content.length;
10451045 content[contentPartCount - 1].cache_control = {
10461046 type: 'ephemeral',