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
Signed| @@ -1040,7 +1040,7 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth, ttl) | |||
| 1040 | text: content, | 1040 | text: content, |
| 1041 | cache_control: { type: 'ephemeral', ttl: ttl }, | 1041 | cache_control: { type: 'ephemeral', ttl: ttl }, |
| 1042 | }]; | 1042 | }]; |
| 1043 | } else { | 1043 | } else if (content?.length > 0) { |
| 1044 | const contentPartCount = content.length; | 1044 | const contentPartCount = content.length; |
| 1045 | content[contentPartCount - 1].cache_control = { | 1045 | content[contentPartCount - 1].cache_control = { |
| 1046 | type: 'ephemeral', | 1046 | type: 'ephemeral', |