mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6693] [Feature]: Prompt caching: Claude subscription history marker, Opus 5.5 SDK, opt-in cache-friendly layout, low-cache warning and diagnostics #3747
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3747
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SirAdoni on GitHub (Sep 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6693
Originally assigned to: @SpicyMarinara on GitHub.
Part of the contribution roadmap in #6624 (package F).
What problem does this solve?
On long chats with a lot of lore, prompt caching decides most of the cost and wait of each turn, and a few things make it miss more than it needs to:
Proposed solution
Build on the existing provider and prompt assembly code rather than restructure it:
prompt_cache_key.MARINARA_CACHE_DIAGNOSTICSlogs hashes, lengths and reported cache usage (never prompt text); Peek Prompt can show the prompt as the next turn will send it; the token usage line adds "N% cached".How it's switched: the layout (
cacheFriendlyPromptLayout) and the per-chat warning (cacheSendGuard) are off by default, and the diagnostics need their environment variable. With all three off, prompts are byte-identical tostaging, checked by a regression that captures the request at the SDK. The marker fix and the SDK bump are bug fixes with no switch.packages/server/src/services/llm/providers: Claude subscription (and itsjsonl-entries), OpenAI, ChatGPT and its cache helper, base provider, cache diagnosticspackages/server/src/services/generation: newprompt-cache-layout.tsandcache-send-guard.ts, memory recall contextpackages/server/src/services/prompt: assembler, marker expander, mergerpackages/server/src/routes: generate (and dry run), chats (Peek Prompt preview)packages/shared/src/schemas: chat metadata, feature switches, GM verb table (two engine-owned metadata prefixes)use-generate,en.jsonpackages/server/package.json,pnpm-workspace.yaml, lockfile; docs underdocs/configurationanddocs/promptsAlternatives considered
Additional context
Screenshots
Taken from the fork build with invented demo data (characters, lorebooks and a campaign made up for these shots). Model replies and token counts come from a local test stub, so no real model was called.
Warn before a low-cache send: the send is held, and the dialog shows the predicted cached share and where the prompt first changed.
Peek Prompt showing the prompt as the next turn will send it, with the chat's enabled lore in one block at the start.
The token usage line with the cached share, and its breakdown (cache read, cache write, hit ratio).
Template check
@SpicyMarinara commented on GitHub (Sep 26, 2026):
Awaiting PR.