[GH-ISSUE #6218] [Issue]: Gemini cache hits are never reported because cachedContentTokenCount is not parsed #3467

Closed
opened 2026-10-21 06:03:24 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Sep 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6218

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The Gemini adapter reads the prompt, candidate, total and thoughts token counts from usageMetadata but never cachedContentTokenCount, so any savings from Gemini's implicit caching are invisible in every token readout.

Expected behavior

The per-message token usage and Peek Prompt show cache hit tokens for Gemini the way they do for Anthropic and OpenAI, so a user can tell whether caching is doing anything.

Actual behavior

GeminiUsageMetadata in packages/server/src/services/llm/providers/google.provider.ts:53-58 declares no cached field. geminiUsage (:564-570) and the two inline usage sites (:1024-1027, :1089-1092) never set cachedPromptTokens, so the readouts have nothing to show.

Steps to reproduce

  1. Use a Gemini connection with a long, stable system prompt.
  2. Turn on Show token usage and send two turns in quick succession.
  3. No cache hit figure appears, even when the API response carries cachedContentTokenCount.

Environment

  • Marinara Engine version: 2.4.5 (staging at 29ee24fc2)
  • Install type: source
  • OS + version: Fedora 44
  • Browser or app shell: not browser-specific; verified by reading the code at the cited lines

Logs, screenshots, or video

Not applicable; the missing field is visible at the cited lines.

Additional context

One field on the interface and one line at each usage site is enough to make it visible. Explicit cachedContents caching is a separate question and probably not worth it while the prompt is refitted before every send; measuring implicit caching first is the cheap step.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Sep 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6218 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The Gemini adapter reads the prompt, candidate, total and thoughts token counts from `usageMetadata` but never `cachedContentTokenCount`, so any savings from Gemini's implicit caching are invisible in every token readout. ## Expected behavior The per-message token usage and Peek Prompt show cache hit tokens for Gemini the way they do for Anthropic and OpenAI, so a user can tell whether caching is doing anything. ## Actual behavior `GeminiUsageMetadata` in `packages/server/src/services/llm/providers/google.provider.ts:53-58` declares no cached field. `geminiUsage` (`:564-570`) and the two inline usage sites (`:1024-1027`, `:1089-1092`) never set `cachedPromptTokens`, so the readouts have nothing to show. ## Steps to reproduce 1. Use a Gemini connection with a long, stable system prompt. 2. Turn on **Show token usage** and send two turns in quick succession. 3. No cache hit figure appears, even when the API response carries `cachedContentTokenCount`. ## Environment - Marinara Engine version: 2.4.5 (staging at 29ee24fc2) - Install type: source - OS + version: Fedora 44 - Browser or app shell: not browser-specific; verified by reading the code at the cited lines ## Logs, screenshots, or video Not applicable; the missing field is visible at the cited lines. ## Additional context One field on the interface and one line at each usage site is enough to make it visible. Explicit `cachedContents` caching is a separate question and probably not worth it while the prompt is refitted before every send; measuring implicit caching first is the cheap step. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:03:24 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 15, 2026):

Owner: @SpicyMarinara, with Codex implementing this issue as part of the requested sweep in draft PR #6230 against staging. I checked the open PRs and issue-linked work before starting; no competing open PR was found.

<!-- gh-comment-id:5677751087 --> @SpicyMarinara commented on GitHub (Sep 15, 2026): Owner: @SpicyMarinara, with Codex implementing this issue as part of the requested sweep in draft PR #6230 against `staging`. I checked the open PRs and issue-linked work before starting; no competing open PR was found.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 15, 2026):

Merged in #6230 to staging (c6685f7034).

Gemini cachedContentTokenCount is now included in reported cached prompt tokens, across direct/Vertex and buffered/streaming request paths. Verified with captured HTTP responses in the provider regression.

<!-- gh-comment-id:5679123608 --> @SpicyMarinara commented on GitHub (Sep 15, 2026): Merged in #6230 to staging (c6685f7034d474bee00db124c4dc6398c5fc2bed). Gemini cachedContentTokenCount is now included in reported cached prompt tokens, across direct/Vertex and buffered/streaming request paths. Verified with captured HTTP responses in the provider regression.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3467
No description provided.