[GH-ISSUE #6341] [Feature]: 1-hour prompt cache option for the Claude (Subscription) provider #3542

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

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

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

The Anthropic (API key) provider has an "Extended token caching (1 hour)" toggle, but the Claude (Subscription) provider has no equivalent. Roleplay chats routinely have gaps of more than 5 minutes between messages, and when the cache lapses the next request re-writes the full context at the cache-write rate, which eats into subscription usage windows.

Users also can't fix this themselves through Claude Code config: the provider passes settingSources: [] (deliberately, to keep Claude Code settings out of chat requests), so promptCacheTtl in ~/.claude/settings.json is never read.

Proposed solution

  1. Add a connection-level "Extended token caching (1 hour)" toggle to the Claude (Subscription) connection, mirroring the Anthropic provider. It could be passed via the inline settings object the provider already sends (settings: { fastMode } -> also promptCacheTtl: "1h"), or by setting CLAUDE_CODE_PROMPT_CACHE_TTL=1h in sdkOptions.env. Requires Claude Code v2.1.242+.
  2. Update the comment and cost multipliers in claude-subscription.provider.ts that state the Agent SDK uses the 5-minute cache (write 1.25x). Per Anthropic's current docs, Agent SDK turns fall in the "main conversation" bucket, which defaults to the 1-hour TTL on a subscription within plan usage (write 2x) and drops to 5 minutes on usage credits or an API key. The cache-economics log may be using the wrong multiplier.
  3. Have the cache log split writes into ephemeral_5m_input_tokens and ephemeral_1h_input_tokens (both are in the usage object under cache_creation), so users can see which TTL they are actually getting.

Alternatives considered

Setting CLAUDE_CODE_PROMPT_CACHE_TTL=1h in Marinara's .env works today as a workaround, since the provider forwards process.env to the SDK subprocess. It's undiscoverable, though, and applies to every subscription connection rather than per connection.

Additional context

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Sep 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6341 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? The Anthropic (API key) provider has an "Extended token caching (1 hour)" toggle, but the Claude (Subscription) provider has no equivalent. Roleplay chats routinely have gaps of more than 5 minutes between messages, and when the cache lapses the next request re-writes the full context at the cache-write rate, which eats into subscription usage windows. Users also can't fix this themselves through Claude Code config: the provider passes `settingSources: []` (deliberately, to keep Claude Code settings out of chat requests), so `promptCacheTtl` in `~/.claude/settings.json` is never read. ## Proposed solution 1. Add a connection-level "Extended token caching (1 hour)" toggle to the Claude (Subscription) connection, mirroring the Anthropic provider. It could be passed via the inline `settings` object the provider already sends (`settings: { fastMode }` -> also `promptCacheTtl: "1h"`), or by setting `CLAUDE_CODE_PROMPT_CACHE_TTL=1h` in `sdkOptions.env`. Requires Claude Code v2.1.242+. 2. Update the comment and cost multipliers in `claude-subscription.provider.ts` that state the Agent SDK uses the 5-minute cache (write 1.25x). Per Anthropic's current docs, Agent SDK turns fall in the "main conversation" bucket, which defaults to the 1-hour TTL on a subscription within plan usage (write 2x) and drops to 5 minutes on usage credits or an API key. The cache-economics log may be using the wrong multiplier. 3. Have the cache log split writes into `ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens` (both are in the usage object under `cache_creation`), so users can see which TTL they are actually getting. ## Alternatives considered Setting `CLAUDE_CODE_PROMPT_CACHE_TTL=1h` in Marinara's `.env` works today as a workaround, since the provider forwards `process.env` to the SDK subprocess. It's undiscoverable, though, and applies to every subscription connection rather than per connection. ## Additional context - Docs: https://code.claude.com/docs/en/prompt-caching (see "Which TTL each request gets" and "Choose the TTL yourself") - I haven't verified the default TTL against live requests; item 3 would make that easy to check. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 18, 2026):

Implementation owner: @SpicyMarinara (Codex), tracked in draft #6342 against staging. I checked open PRs and issue-linked branch names before starting; none overlap these fixes. Reproduction and regression proof are in progress.

<!-- gh-comment-id:5737247684 --> @SpicyMarinara commented on GitHub (Sep 18, 2026): Implementation owner: @SpicyMarinara (Codex), tracked in draft #6342 against staging. I checked open PRs and issue-linked branch names before starting; none overlap these fixes. Reproduction and regression proof are in progress.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 19, 2026):

Implemented in #6342, now merged into staging. Claude Subscription supports the existing one-hour cache setting, including save/reload and unsaved exports. Cache logs distinguish reported five-minute and one-hour writes; incomplete usage leaves estimates unknown. SDK and desktop/mobile regressions pass; live subscription expiry testing remains documented in the PR.

<!-- gh-comment-id:5737714459 --> @SpicyMarinara commented on GitHub (Sep 19, 2026): Implemented in #6342, now merged into staging. Claude Subscription supports the existing one-hour cache setting, including save/reload and unsaved exports. Cache logs distinguish reported five-minute and one-hour writes; incomplete usage leaves estimates unknown. SDK and desktop/mobile regressions pass; live subscription expiry testing remains documented in the PR.
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#3542
No description provided.