[PR #8748] [MERGED] feat(capabilities): a package call can ask for a 1-hour cache on its marked prompt (API 1.815) #8782

Closed
opened 2026-11-07 17:39:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8748
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/capability-cache-ttl


📝 Commits (2)

  • e0bcc7a feat(capabilities): a package call can ask for a 1-hour cache on its marked prompt (API 1.815)
  • 7d58c4c Merge branch 'staging' into feat/capability-cache-ttl

📊 Changes

6 files changed (+58 additions, -5 deletions)

View changed files

📝 docs/development/optional-agent-packages.md (+12 -0)
📝 packages/server/src/services/capability-packages/capability-language-model.service.ts (+3 -2)
📝 packages/shared/src/schemas/capability-package.schema.ts (+4 -1)
📝 packages/shared/src/types/capability-runtime.ts (+6 -0)
📝 scripts/regressions/capability-language-model-prompt-cache.regression.ts (+31 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+2 -2)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8746

Why this change

Otome Hearth marks its story context for caching (1.814), but the cache time comes from the connection: 5 minutes unless "Extended token caching (1 hour)" is on. A scene is written when the player reaches the previous one, usually more than 5 minutes apart, so the cached context expired between scenes and every scene paid the cache-write price again. The maintainer's Anthropic usage on 2026-11-03 showed about 534k cache-write tokens against 30k cache reads in four hours. The maintainer asked for the 1-hour cache in Otome Hearth on Anthropic connections; this is the Engine side of that.

What changed

  • Capability API 1.815: CapabilityLanguageModelCompletionOptions.cacheTtl?: "5m" | "1h" (packages/shared/src/types/capability-runtime.ts), with supportedCapabilityApi bumped to {1, 815} and its history line.
  • capability-language-model.service.ts: for a call with marked messages, anthropicExtendedCacheTtl follows the call's cacheTtl when it has one, and otherwise the connection's switch, as before.
    • Unmarked calls are unchanged and get no cache at all.
    • Providers that cache on their own, and Claude (Subscription), ignore the option.
    • Older Engines ignore it, so a package can always pass it.
  • Docs: a "Capability API 1.815" section in docs/development/optional-agent-packages.md. The translated packs are tracked in a [docs-i18n] follow-up issue.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

What the agent ran:

  • pnpm check passes (exit 0). The 12 existing client lint warnings are in files this PR doesn't touch.

  • scripts/regressions/capability-language-model-prompt-cache.regression.ts (real Anthropic request bodies against a loopback fixture) now covers:

    • a call asking for 1h on a 5-minute connection gets ttl: "1h" on its marked blocks;
    • a call asking for 5m on a 1-hour connection gets the 5-minute TTL;
    • a call that leaves cacheTtl out keeps the connection's 1 hour;
    • an unmarked call that asks for 1h still sends no cache_control.

    It fails without the service change.

  • node ./scripts/run-regressions.mjs --filter capability: 29/29 pass. The lifecycle regression now pins 1.815.

Manual verification notes

  • Manually verify with a package that marks a prefix and passes cacheTtl: "1h" on an Anthropic connection whose 1-hour cache is off: Anthropic's usage shows "Cache write (1h)" for those calls, and reads on calls within the hour.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8748 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/3/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/capability-cache-ttl` --- ### 📝 Commits (2) - [`e0bcc7a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e0bcc7a3a4e80e48e0279256ca8ec90ba9f3ae71) feat(capabilities): a package call can ask for a 1-hour cache on its marked prompt (API 1.815) - [`7d58c4c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7d58c4c46bbd7df1f5163e07cd6c1f733863b1e5) Merge branch 'staging' into feat/capability-cache-ttl ### 📊 Changes **6 files changed** (+58 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/optional-agent-packages.md` (+12 -0) 📝 `packages/server/src/services/capability-packages/capability-language-model.service.ts` (+3 -2) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+4 -1) 📝 `packages/shared/src/types/capability-runtime.ts` (+6 -0) 📝 `scripts/regressions/capability-language-model-prompt-cache.regression.ts` (+31 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+2 -2) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #8746 ## Why this change Otome Hearth marks its story context for caching (1.814), but the cache time comes from the connection: 5 minutes unless "Extended token caching (1 hour)" is on. A scene is written when the player reaches the previous one, usually more than 5 minutes apart, so the cached context expired between scenes and every scene paid the cache-write price again. The maintainer's Anthropic usage on 2026-11-03 showed about 534k cache-write tokens against 30k cache reads in four hours. The maintainer asked for the 1-hour cache in Otome Hearth on Anthropic connections; this is the Engine side of that. ## What changed - **Capability API 1.815:** `CapabilityLanguageModelCompletionOptions.cacheTtl?: "5m" | "1h"` (`packages/shared/src/types/capability-runtime.ts`), with `supportedCapabilityApi` bumped to `{1, 815}` and its history line. - **`capability-language-model.service.ts`:** for a call with marked messages, `anthropicExtendedCacheTtl` follows the call's `cacheTtl` when it has one, and otherwise the connection's switch, as before. - Unmarked calls are unchanged and get no cache at all. - Providers that cache on their own, and Claude (Subscription), ignore the option. - Older Engines ignore it, so a package can always pass it. - **Docs:** a "Capability API 1.815" section in `docs/development/optional-agent-packages.md`. The translated packs are tracked in a `[docs-i18n]` follow-up issue. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` What the agent ran: - `pnpm check` passes (exit 0). The 12 existing client lint warnings are in files this PR doesn't touch. - `scripts/regressions/capability-language-model-prompt-cache.regression.ts` (real Anthropic request bodies against a loopback fixture) now covers: - a call asking for 1h on a 5-minute connection gets `ttl: "1h"` on its marked blocks; - a call asking for 5m on a 1-hour connection gets the 5-minute TTL; - a call that leaves `cacheTtl` out keeps the connection's 1 hour; - an unmarked call that asks for 1h still sends no `cache_control`. It fails without the service change. - `node ./scripts/run-regressions.mjs --filter capability`: 29/29 pass. The lifecycle regression now pins 1.815. ### Manual verification notes - Manually verify with a package that marks a prefix and passes `cacheTtl: "1h"` on an Anthropic connection whose 1-hour cache is off: Anthropic's usage shows "Cache write (1h)" for those calls, and reads on calls within the hour. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:39 +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#8782
No description provided.