Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaggy-turtles-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-cline": patch
---

Disable Gemini prompt caching
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Roo Code Changelog

## [3.14.1] - 2025-04-24

- Disable Gemini caching while we investigate issues reported by the community.

## [3.14.0] - 2025-04-23

- Add prompt caching for `gemini-2.5-pro-preview-03-25` in the Gemini provider (Vertex and OpenRouter coming soon!)
Expand Down
46 changes: 23 additions & 23 deletions src/api/providers/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
let cacheWriteTokens: number | undefined = undefined

// https://ai.google.dev/gemini-api/docs/caching?lang=node
if (info.supportsPromptCache && cacheKey) {
const cacheEntry = this.contentCaches.get(cacheKey)
// if (info.supportsPromptCache && cacheKey) {
// const cacheEntry = this.contentCaches.get(cacheKey)

if (cacheEntry) {
uncachedContent = contents.slice(cacheEntry.count, contents.length)
cachedContent = cacheEntry.key
}
// if (cacheEntry) {
// uncachedContent = contents.slice(cacheEntry.count, contents.length)
// cachedContent = cacheEntry.key
// }

const newCacheEntry = await this.client.caches.create({
model,
config: { contents, systemInstruction, ttl: `${CACHE_TTL * 60}s` },
})
// const newCacheEntry = await this.client.caches.create({
// model,
// config: { contents, systemInstruction, ttl: `${CACHE_TTL * 60}s` },
// })

if (newCacheEntry.name) {
this.contentCaches.set(cacheKey, { key: newCacheEntry.name, count: contents.length })
cacheWriteTokens = newCacheEntry.usageMetadata?.totalTokenCount ?? 0
}
}
// if (newCacheEntry.name) {
// this.contentCaches.set(cacheKey, { key: newCacheEntry.name, count: contents.length })
// cacheWriteTokens = newCacheEntry.usageMetadata?.totalTokenCount ?? 0
// }
// }

const params: GenerateContentParameters = {
model,
Expand Down Expand Up @@ -94,13 +94,13 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
const cacheReadTokens = lastUsageMetadata.cachedContentTokenCount
const reasoningTokens = lastUsageMetadata.thoughtsTokenCount

const totalCost = this.calculateCost({
info,
inputTokens,
outputTokens,
cacheWriteTokens,
cacheReadTokens,
})
// const totalCost = this.calculateCost({
// info,
// inputTokens,
// outputTokens,
// cacheWriteTokens,
// cacheReadTokens,
// })

yield {
type: "usage",
Expand All @@ -109,7 +109,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
cacheWriteTokens,
cacheReadTokens,
reasoningTokens,
totalCost,
// totalCost,
}
}
}
Expand Down
31 changes: 20 additions & 11 deletions src/api/providers/openrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,13 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH

// Prompt caching: https://openrouter.ai/docs/prompt-caching
// Now with Gemini support: https://openrouter.ai/docs/features/prompt-caching
if (supportsPromptCache) {
// Note that we don't check the `ModelInfo` object because it is cached
// in the settings for OpenRouter.
if (this.isPromptCacheSupported(modelId)) {
openAiMessages[0] = {
role: "system",
content: [
{
type: "text",
text: systemPrompt,
// @ts-ignore-next-line
cache_control: { type: "ephemeral" },
},
],
// @ts-ignore-next-line
content: [{ type: "text", text: systemPrompt, cache_control: { type: "ephemeral" } }],
}

// Add cache_control to the last two user messages
Expand All @@ -108,13 +104,17 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
}

if (Array.isArray(msg.content)) {
// NOTE: this is fine since env details will always be added at the end. but if it weren't there, and the user added a image_url type message, it would pop a text part before it and then move it after to the end.
// NOTE: This is fine since env details will always be added
// at the end. But if it wasn't there, and the user added a
// image_url type message, it would pop a text part before
// it and then move it after to the end.
let lastTextPart = msg.content.filter((part) => part.type === "text").pop()

if (!lastTextPart) {
lastTextPart = { type: "text", text: "..." }
msg.content.push(lastTextPart)
}

// @ts-ignore-next-line
lastTextPart["cache_control"] = { type: "ephemeral" }
}
Expand Down Expand Up @@ -227,6 +227,15 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
const completion = response as OpenAI.Chat.ChatCompletion
return completion.choices[0]?.message?.content || ""
}

private isPromptCacheSupported(modelId: string) {
return (
modelId.startsWith("anthropic/claude-3.7-sonnet") ||
modelId.startsWith("anthropic/claude-3.5-sonnet") ||
modelId.startsWith("anthropic/claude-3-opus") ||
modelId.startsWith("anthropic/claude-3-haiku")
)
}
}

export async function getOpenRouterModels(options?: ApiHandlerOptions) {
Expand All @@ -250,7 +259,7 @@ export async function getOpenRouterModels(options?: ApiHandlerOptions) {
thinking: rawModel.id === "anthropic/claude-3.7-sonnet:thinking",
}

// NOTE: this needs to be synced with api.ts/openrouter default model info.
// NOTE: This needs to be synced with api.ts/openrouter default model info.
switch (true) {
case rawModel.id.startsWith("anthropic/claude-3.7-sonnet"):
modelInfo.supportsComputerUse = true
Expand Down
6 changes: 3 additions & 3 deletions src/shared/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export const geminiModels = {
maxTokens: 65_535,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
supportsPromptCache: false,
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
Expand All @@ -706,7 +706,7 @@ export const geminiModels = {
maxTokens: 8192,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
supportsPromptCache: false,
inputPrice: 0.1,
outputPrice: 0.4,
cacheReadsPrice: 0.025,
Expand Down Expand Up @@ -756,7 +756,7 @@ export const geminiModels = {
maxTokens: 8192,
contextWindow: 1_048_576,
supportsImages: true,
supportsPromptCache: true,
supportsPromptCache: false,
inputPrice: 0.15, // This is the pricing for prompts above 128k tokens.
outputPrice: 0.6,
cacheReadsPrice: 0.0375,
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ca/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 publicat",
"description": "Roo Code 3.14 porta noves funcionalitats i millores basades en els teus comentaris.",
"whatsNew": "Novetats",
"feature1": "<bold>Memòria cau per a Gemini 2.5 Pro</bold>: <code>gemini-2.5-pro-preview-03-25</code> ara suporta memòria cau de prompts al proveïdor Gemini (Vertex i OpenRouter disponibles aviat)",
"feature2": "<bold>Eines d'edició millorades</bold>: Les eines <code>search_and_replace</code> i <code>insert_content</code> han estat millorades i ja no són experimentals",
"feature1": "<bold>Eines d'edició millorades</bold>: Les eines <code>search_and_replace</code> i <code>insert_content</code> han estat millorades i ja no són experimentals",
"feature2": "<bold>Millores a apply_diff</bold>: Continuem treballant per millorar l'eina <code>apply_diff</code>",
"feature3": "<bold>Moltes altres millores</bold>: Nombroses correccions i optimitzacions a tota l'extensió",
"hideButton": "Amagar anunci",
"detailsDiscussLinks": "Obtingues més detalls i participa a <discordLink>Discord</discordLink> i <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/de/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 veröffentlicht",
"description": "Roo Code 3.14 bringt neue Funktionen und Verbesserungen basierend auf deinem Feedback.",
"whatsNew": "Was ist neu",
"feature1": "<bold>Gemini 2.5 Pro Caching</bold>: <code>gemini-2.5-pro-preview-03-25</code> unterstützt jetzt Prompt-Caching im Gemini-Provider (Vertex und OpenRouter folgen bald)",
"feature2": "<bold>Verbesserte Bearbeitungswerkzeuge</bold>: Die <code>search_and_replace</code> und <code>insert_content</code> Tools wurden verbessert und sind nicht mehr experimentell",
"feature1": "<bold>Verbesserte Bearbeitungswerkzeuge</bold>: Die <code>search_and_replace</code> und <code>insert_content</code> Tools wurden verbessert und sind nicht mehr experimentell",
"feature2": "<bold>Diff Apply Fixes</bold>: Wir arbeiten weiterhin an der Verbesserung des <code>apply_diff</code> Tools",
"feature3": "<bold>Zahlreiche andere Verbesserungen</bold>: Viele Fehlerbehebungen und Optimierungen in der gesamten Erweiterung",
"hideButton": "Ankündigung ausblenden",
"detailsDiscussLinks": "Erhalte mehr Details und diskutiere auf <discordLink>Discord</discordLink> und <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/en/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
"title": "🎉 Roo Code 3.14 Released",
"description": "Roo Code 3.14 brings new features and improvements based on your feedback.",
"whatsNew": "What's New",
"feature1": "<bold>Gemini 2.5 Pro Caching</bold>: <code>gemini-2.5-pro-preview-03-25</code> now supports prompt caching in the Gemini provider (Vertex and OpenRouter coming soon)",
"feature2": "<bold>Improved Editing Tools</bold>: The <code>search_and_replace</code> and <code>insert_content</code> tools have been improved and graduated from experimental status",
"feature1": "<bold>Improved Editing Tools</bold>: The <code>search_and_replace</code> and <code>insert_content</code> tools have been improved and graduated from experimental status",
"feature2": "<bold>Diff Apply Fixes</bold>: We continue to work on improving the <code>apply_diff</code> tool",
"feature3": "<bold>Tons of Other Improvements</bold>: Numerous fixes and enhancements throughout the extension",
"hideButton": "Hide announcement",
"detailsDiscussLinks": "Get more details and discuss in <discordLink>Discord</discordLink> and <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/es/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 publicado",
"description": "Roo Code 3.14 trae nuevas funcionalidades y mejoras basadas en tus comentarios.",
"whatsNew": "Novedades",
"feature1": "<bold>Caché para Gemini 2.5 Pro</bold>: <code>gemini-2.5-pro-preview-03-25</code> ahora admite caché de prompts en el proveedor Gemini (Vertex y OpenRouter próximamente)",
"feature2": "<bold>Herramientas de edición mejoradas</bold>: Las herramientas <code>search_and_replace</code> y <code>insert_content</code> han sido mejoradas y ya no son experimentales",
"feature1": "<bold>Herramientas de edición mejoradas</bold>: Las herramientas <code>search_and_replace</code> y <code>insert_content</code> han sido mejoradas y ya no son experimentales",
"feature2": "<bold>Mejoras en apply_diff</bold>: Continuamos trabajando en mejorar la herramienta <code>apply_diff</code>",
"feature3": "<bold>Montones de otras mejoras</bold>: Numerosas correcciones y mejoras en toda la extensión",
"hideButton": "Ocultar anuncio",
"detailsDiscussLinks": "Obtén más detalles y participa en <discordLink>Discord</discordLink> y <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/fr/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 est sortie",
"description": "Roo Code 3.14 apporte de nouvelles fonctionnalités et améliorations basées sur vos retours.",
"whatsNew": "Quoi de neuf",
"feature1": "<bold>Cache pour Gemini 2.5 Pro</bold> : <code>gemini-2.5-pro-preview-03-25</code> prend maintenant en charge le cache des prompts dans le fournisseur Gemini (Vertex et OpenRouter bientôt disponibles)",
"feature2": "<bold>Outils d'édition améliorés</bold> : Les outils <code>search_and_replace</code> et <code>insert_content</code> ont été améliorés et ne sont plus expérimentaux",
"feature1": "<bold>Outils d'édition améliorés</bold> : Les outils <code>search_and_replace</code> et <code>insert_content</code> ont été améliorés et ne sont plus expérimentaux",
"feature2": "<bold>Corrections pour apply_diff</bold> : Nous continuons à travailler sur l'amélioration de l'outil <code>apply_diff</code>",
"feature3": "<bold>Quantité d'autres améliorations</bold> : Nombreuses corrections et optimisations dans toute l'extension",
"hideButton": "Masquer l'annonce",
"detailsDiscussLinks": "Obtenez plus de détails et participez aux discussions sur <discordLink>Discord</discordLink> et <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/hi/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 रिलीज़ हुआ",
"description": "Roo Code 3.14 आपके फीडबैक के आधार पर नई सुविधाएँ और सुधार लाता है।",
"whatsNew": "नई सुविधाएँ",
"feature1": "<bold>Gemini 2.5 Pro कैशिंग</bold>: <code>gemini-2.5-pro-preview-03-25</code> अब Gemini प्रोवाइडर में प्रॉम्प्ट कैशिंग का समर्थन करता है (Vertex और OpenRouter जल्द ही आ रहे हैं)",
"feature2": "<bold>सुधारित संपादन टूल्स</bold>: <code>search_and_replace</code> और <code>insert_content</code> टूल्स को सुधारा गया है और अब ये प्रयोगात्मक स्थिति से निकल गए हैं",
"feature1": "<bold>सुधारित संपादन टूल्स</bold>: <code>search_and_replace</code> और <code>insert_content</code> टूल्स को सुधारा गया है और अब ये प्रयोगात्मक स्थिति से निकल गए हैं",
"feature2": "<bold>apply_diff सुधार</bold>: हम <code>apply_diff</code> टूल को सुधारने पर निरंतर काम कर रहे हैं",
"feature3": "<bold>ढेरों अन्य सुधार</bold>: एक्सटेंशन में अनगिनत बग फिक्स और विकास",
"hideButton": "घोषणा छिपाएँ",
"detailsDiscussLinks": "<discordLink>Discord</discordLink> और <redditLink>Reddit</redditLink> पर अधिक जानकारी प्राप्त करें और चर्चा में भाग लें 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/it/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Rilasciato Roo Code 3.14",
"description": "Roo Code 3.14 porta nuove funzionalità e miglioramenti basati sui tuoi feedback.",
"whatsNew": "Novità",
"feature1": "<bold>Cache per Gemini 2.5 Pro</bold>: <code>gemini-2.5-pro-preview-03-25</code> ora supporta la cache dei prompt nel provider Gemini (Vertex e OpenRouter presto disponibili)",
"feature2": "<bold>Strumenti di modifica migliorati</bold>: Gli strumenti <code>search_and_replace</code> e <code>insert_content</code> sono stati migliorati e non sono più sperimentali",
"feature1": "<bold>Strumenti di modifica migliorati</bold>: Gli strumenti <code>search_and_replace</code> e <code>insert_content</code> sono stati migliorati e non sono più sperimentali",
"feature2": "<bold>Correzioni per apply_diff</bold>: Continuiamo a lavorare per migliorare lo strumento <code>apply_diff</code>",
"feature3": "<bold>Tantissimi altri miglioramenti</bold>: Numerose correzioni e ottimizzazioni in tutta l'estensione",
"hideButton": "Nascondi annuncio",
"detailsDiscussLinks": "Ottieni maggiori dettagli e partecipa alle discussioni su <discordLink>Discord</discordLink> e <redditLink>Reddit</redditLink> 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ja/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 リリース",
"description": "Roo Code 3.14は新機能とあなたのフィードバックに基づく改善をもたらします。",
"whatsNew": "新機能",
"feature1": "<bold>Gemini 2.5 Proのプロンプトキャッシング</bold>: <code>gemini-2.5-pro-preview-03-25</code>がGeminiプロバイダーでプロンプトキャッシングをサポートするようになりました(VertexとOpenRouterも近日対応予定)",
"feature2": "<bold>編集ツールの改善</bold>: <code>search_and_replace</code>と<code>insert_content</code>ツールが改善され、実験的ステータスから正式機能になりました",
"feature1": "<bold>編集ツールの改善</bold>: <code>search_and_replace</code>と<code>insert_content</code>ツールが改善され、実験的ステータスから正式機能になりました",
"feature2": "<bold>apply_diffの修正</bold>: <code>apply_diff</code>ツールの改善に継続的に取り組んでいます",
"feature3": "<bold>その他多数の改善点</bold>: 拡張機能全体にわたる多くの修正と機能強化",
"hideButton": "通知を非表示",
"detailsDiscussLinks": "詳細は<discordLink>Discord</discordLink>と<redditLink>Reddit</redditLink>でご確認・ディスカッションください 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/ko/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 출시",
"description": "Roo Code 3.14는 사용자 피드백을 기반으로 새로운 기능과 개선사항을 제공합니다.",
"whatsNew": "새로운 기능",
"feature1": "<bold>Gemini 2.5 Pro 캐싱</bold>: <code>gemini-2.5-pro-preview-03-25</code>에서 이제 Gemini 제공자에서 프롬프트 캐싱을 지원합니다 (Vertex 및 OpenRouter 지원 예정)",
"feature2": "<bold>개선된 편집 도구</bold>: <code>search_and_replace</code>와 <code>insert_content</code> 도구가 개선되어 실험 상태에서 정식 기능으로 전환되었습니다",
"feature1": "<bold>개선된 편집 도구</bold>: <code>search_and_replace</code>와 <code>insert_content</code> 도구가 개선되어 실험 상태에서 정식 기능으로 전환되었습니다",
"feature2": "<bold>apply_diff 수정</bold>: <code>apply_diff</code> 도구를 지속적으로 개선하고 있습니다",
"feature3": "<bold>수많은 기타 개선사항</bold>: 확장 프로그램 전체에 걸친 다양한 수정 및 향상된 기능",
"hideButton": "공지 숨기기",
"detailsDiscussLinks": "<discordLink>Discord</discordLink>와 <redditLink>Reddit</redditLink>에서 더 자세한 정보를 확인하고 논의하세요 🚀"
Expand Down
4 changes: 2 additions & 2 deletions webview-ui/src/i18n/locales/pl/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@
"title": "🎉 Roo Code 3.14 wydany",
"description": "Roo Code 3.14 przynosi nowe funkcje i ulepszenia na podstawie Twoich opinii.",
"whatsNew": "Co nowego",
"feature1": "<bold>Pamięć podręczna dla Gemini 2.5 Pro</bold>: <code>gemini-2.5-pro-preview-03-25</code> teraz obsługuje pamięć podręczną promptów w dostawcy Gemini (Vertex i OpenRouter wkrótce)",
"feature2": "<bold>Ulepszone narzędzia edycji</bold>: Narzędzia <code>search_and_replace</code> i <code>insert_content</code> zostały ulepszone i nie są już eksperymentalne",
"feature1": "<bold>Ulepszone narzędzia edycji</bold>: Narzędzia <code>search_and_replace</code> i <code>insert_content</code> zostały ulepszone i nie są już eksperymentalne",
"feature2": "<bold>Poprawki apply_diff</bold>: Kontynuujemy pracę nad ulepszaniem narzędzia <code>apply_diff</code>",
"feature3": "<bold>Mnóstwo innych ulepszeń</bold>: Liczne poprawki i usprawnienia w całym rozszerzeniu",
"hideButton": "Ukryj ogłoszenie",
"detailsDiscussLinks": "Uzyskaj więcej szczegółów i dołącz do dyskusji na <discordLink>Discord</discordLink> i <redditLink>Reddit</redditLink> 🚀"
Expand Down
Loading