diff --git a/src/prompt-converters.js b/src/prompt-converters.js index 73fc6a23d..f151a6b30 100644 --- a/src/prompt-converters.js +++ b/src/prompt-converters.js @@ -1026,6 +1026,11 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth, ttl) passedThePrefill = true; + // Skip system messages so they don't affect depth counting or receive cache breakpoints + if (messages[i].role === 'system') { + continue; + } + if (messages[i].role !== previousRoleName) { if (depth === cachingAtDepth || depth === cachingAtDepth + 2) { const content = messages[i].content;