[GH-ISSUE #5763] Context usage indicator omits Anthropic prompt-cache tokens #3185

Closed
opened 2026-10-21 06:00:19 +07:00 by bsakaguchi · 0 comments
Owner

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

$## Bug Report\n\n### Summary\nThe context usage indicator can show a very small value in long chats when an Anthropic connection serves most of the prompt from its cache.\n\n### Observed behavior\nA long roleplay chat can show about 3.5k tokens even after hundreds of messages.\n\n### Expected behavior\nThe indicator should include fresh input tokens, cache-read input tokens, cache-write input tokens, and the current assistant response. Cached tokens still belong to the active model context.\n\n### Root cause\nAnthropic returns input_tokens, cache_read_input_tokens, and cache_creation_input_tokens separately. The usage persistence path stored only input_tokens, and the client calculation could not include the cached prompt.\n\n### Scope\nThis report targets Anthropic API and Claude subscription connections with prompt caching enabled.\n\n### Proposed fix\nPersist Anthropic cache usage fields and include them in the context indicator. Add regression coverage for cached long-chat usage.\n\n### Environment\nReported on Marinara Engine 2.4.5, Android/Termux, Claude Opus 4.6 via the Anthropic provider.

Originally created by @Gunterlie on GitHub (Sep 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5763 $## Bug Report\n\n### Summary\nThe context usage indicator can show a very small value in long chats when an Anthropic connection serves most of the prompt from its cache.\n\n### Observed behavior\nA long roleplay chat can show about 3.5k tokens even after hundreds of messages.\n\n### Expected behavior\nThe indicator should include fresh input tokens, cache-read input tokens, cache-write input tokens, and the current assistant response. Cached tokens still belong to the active model context.\n\n### Root cause\nAnthropic returns `input_tokens`, `cache_read_input_tokens`, and `cache_creation_input_tokens` separately. The usage persistence path stored only `input_tokens`, and the client calculation could not include the cached prompt.\n\n### Scope\nThis report targets Anthropic API and Claude subscription connections with prompt caching enabled.\n\n### Proposed fix\nPersist Anthropic cache usage fields and include them in the context indicator. Add regression coverage for cached long-chat usage.\n\n### Environment\nReported on Marinara Engine 2.4.5, Android/Termux, Claude Opus 4.6 via the Anthropic provider.
bsakaguchi 2026-10-21 06:00:19 +07:00
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#3185
No description provided.