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:
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user