mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8698] [MERGED] feat(packages): cache a package's stable prompt prefix on Anthropic (capability API 1.814) #8751
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#8751
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/8698
Author: @SpicyMarinara
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/package-prompt-cache📝 Commits (2)
5bbe1f3feat(packages): cache a package's stable prompt prefix on Anthropic (capability API 1.814)e47264ffix(packages): keep caching when a marked package message is empty📊 Changes
8 files changed (+411 additions, -49 deletions)
View changed files
📝
docs/development/optional-agent-packages.md(+42 -0)📝
packages/server/src/services/capability-packages/capability-language-model.service.ts(+7 -0)📝
packages/server/src/services/llm/providers/anthropic.provider.ts(+87 -45)📝
packages/shared/src/schemas/capability-package.schema.ts(+5 -1)📝
packages/shared/src/types/capability-runtime.ts(+17 -0)📝
packages/shared/src/types/generation-integration.ts(+5 -0)➕
scripts/regressions/capability-language-model-prompt-cache.regression.ts(+244 -0)📝
scripts/regressions/capability-package-lifecycle.regression.ts(+4 -3)📄 Description
Linked issue
Closes #8695
Why this change
capability-language-model.service.ts) passed no caching options, so package calls were never cached, even on connections with prompt caching on.The maintainer decided that marked package calls are always cached, whatever the connection's caching switch.
What changed
CapabilityLanguageModelMessagegainscacheBreakpoint?: boolean: "cache the prompt up to and including this message".cachedPromptTokensandcacheWritePromptTokens.anthropic.provider.ts: both the plain and the tool-round request paths putcache_controlon exactly the marked blocks.cache_control.anthropicSystemField.capability-language-model.service.ts: a marked call is cached whatever the connection's caching switch, for the connection's cache time: 1 h with extended TTL on, else 5 minutes.openai.provider.tshas no per-partcache_control, so markers do nothing there. That needs new message-part formatting in a follow-up./api/generate/raw(browser packages): its strict message schema doesn't accept the field.docs/development/optional-agent-packages.mdgains a 1.814 section. It explains howpromptTokensrelates to the cache counts: on Anthropic it's the uncached part only; on OpenAI-compatible routes and Gemini it already includes them. The type comments say the same. The translated packs are tracked in #8697.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What the agent ran locally, rebased on staging
95f7a322b9:node ./scripts/pnpm-runner.mjs check: exit 0, with only the existing client react-hooks warnings.New regression:
scripts/regressions/capability-language-model-prompt-cache.regression.ts, run over a fake Anthropic server. It checks that:cache_controllands exactly on the marked system and user blocks, with a 5 m or 1 h TTL;cache_control;cache_control.It fails on the pre-change server code at its first assertion.
Related regressions: provider-caching, capability-package-lifecycle (updated for 1.814), claude-subscription-cache, anthropic-safe-retry, provider-tool-history-shape, agent-connection-parameters, generation-usage, openai-prompt-cache-key and the Claude model regressions all pass.
Review: an independent review found two low-severity issues, both fixed above: the empty marked message, and the undocumented
promptTokensmeaning.For a human to verify:
cacheBreakpoint: trueon its stable system message. In the[debug/anthropic] final requestdebug log, manually verifycache_controlis on that block. Then verify the provider reports a cache write on the first call and a cache read on the next one within 5 minutes.ttl: "1h"and Anthropic accepts the request.cache_controlwhile caching is off).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)The English doc
docs/development/optional-agent-packages.mdis updated; the translations follow in #8697.UI evidence (if applicable)
No UI change.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.