mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7866] [MERGED] fix(claude-subscription): mark a history turn so the next request reuses the cached chat #7974
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#7974
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7866
Author: @stonebystone
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/claude-sub-history-cache📝 Commits (7)
6a5cbeffix(claude-subscription): mark a history turn so the next request reuses the cached chat86e4359fix(claude-subscription): add the history marker only with the 1-hour cache ondd26228docs(claude-subscription): say the 1-hour cache also lets history be reused5f164aafix(claude-subscription): keep the history marker on tool-only repliesf8e47c3fix(claude-subscription): pass the history marker past empty replies; plain-English docs1853177fix(claude-subscription): log where the history marker lands; clearer docs wording3f2421dfix(claude-subscription): one-based entry position in the cache-marker debug line📊 Changes
4 files changed (+104 additions, -4 deletions)
View changed files
📝
docs/connections/subscription-clis.md(+2 -0)📝
packages/server/src/services/llm/providers/claude-subscription.provider.ts(+13 -4)📝
packages/server/src/services/llm/providers/claude-subscription/jsonl-entries.ts(+21 -0)📝
scripts/regressions/claude-subscription-cache.regression.ts(+68 -0)📄 Description
Linked issue
Closes #7865
Why this change
On Claude (Subscription), every turn re-writes the whole chat history to the prompt cache and reads back only the system prompt. Claude Code marks just the system prompt and the current turn, and Marinara's current turn carries per-turn blocks (tracker context,
<last_message>, depth-0 sections) that are gone from it a turn later. So each turn re-writes the whole history in the prompt, up to Claude's context limit on a long chat, against the user's subscription. In the reported 130k-token chat that was about 125k cache-write tokens per turn.What changed
assembleEntries(claude-subscriptionjsonl-entries.ts) takes an optionalhistoryCacheControland puts it on the newest assistant reply that is not the last history entry. The last entry is skipped because prompt wrappers such as xml</chat_history>ride on it and move every turn.ponytail:comment).docs/connections/subscription-clis.md: one paragraph saying the 1-hour cache setting also lets the chat history be reused, and that with it off only the system prompt is. Translations follow in #7867.claude-subscription-cacheregression: checks there is exactly one 1h history marker, on the right reply, and none with the 1-hour cache off.Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run checks (for the reviewer, not ticked above):
pnpm check: passes (one existing client lint warning, unrelated).claude-subscription-cacheregression passes, and fails with the marker removed. The other five Claude regressions pass.</chat_history>on the last history message):Manual verification notes
tokensCachedPromptclose to the prompt size).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)cc @SpicyMarinara
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.