[GH-ISSUE #6217] [Issue]: OpenRouter prompt caching is gated on the base URL while the toggle is shown by provider kind #3465

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The Prompt caching toggle is shown for every OpenRouter connection, but the request-side write of cache_control only happens when the connection's base URL contains openrouter.ai. An OpenRouter connection that points at a proxy or gateway host stores the toggle on and never sends the field.

Expected behavior

The toggle and the wire behaviour agree. Either the write keys on the provider kind, like the rest of the OpenRouter handling in the same file, or the toggle is hidden or explained when the base URL does not qualify.

Actual behavior

shouldUseOpenRouterPromptCaching in packages/server/src/services/llm/providers/openai.provider.ts:1042-1043 requires this.baseUrl.includes("openrouter.ai"). The broader OpenRouter test in the same file (:825) accepts providerKind === "openrouter" on its own. The Prompt caching field group in packages/client/src/components/connections/ConnectionEditor.tsx (label at :2833) is rendered by provider kind. The user sees cache hit 0 on every turn with nothing saying why.

Steps to reproduce

  1. Create an OpenRouter connection whose base URL is a proxy or gateway host rather than openrouter.ai.
  2. Turn Prompt caching on and save.
  3. Send a turn with debug logging on. The [OpenAI] Enabling OpenRouter prompt caching line (openai.provider.ts:1049) never fires and the request body carries no cache_control.

Environment

  • Marinara Engine version: 2.4.5 (staging at 29ee24fc2)
  • Install type: source
  • OS + version: Fedora 44
  • Browser or app shell: not browser-specific; verified by reading the code at the cited lines

Logs, screenshots, or video

Not applicable; the gate is visible at the cited lines.

Additional context

A second thing worth checking while fixing this: the field is sent as a top-level body key (openai.provider.ts:1048, pinned by scripts/regressions/provider-compat.regression.ts:392-395), while OpenRouter documents Anthropic-style caching as a per-content-part breakpoint inside messages[].content[]. Nothing in the tree proves the top-level form works. A capture of one real request and its cachedPromptTokens would settle it.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Sep 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6217 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The Prompt caching toggle is shown for every OpenRouter connection, but the request-side write of `cache_control` only happens when the connection's base URL contains `openrouter.ai`. An OpenRouter connection that points at a proxy or gateway host stores the toggle on and never sends the field. ## Expected behavior The toggle and the wire behaviour agree. Either the write keys on the provider kind, like the rest of the OpenRouter handling in the same file, or the toggle is hidden or explained when the base URL does not qualify. ## Actual behavior `shouldUseOpenRouterPromptCaching` in `packages/server/src/services/llm/providers/openai.provider.ts:1042-1043` requires `this.baseUrl.includes("openrouter.ai")`. The broader OpenRouter test in the same file (`:825`) accepts `providerKind === "openrouter"` on its own. The Prompt caching field group in `packages/client/src/components/connections/ConnectionEditor.tsx` (label at `:2833`) is rendered by provider kind. The user sees `cache hit 0` on every turn with nothing saying why. ## Steps to reproduce 1. Create an OpenRouter connection whose base URL is a proxy or gateway host rather than `openrouter.ai`. 2. Turn **Prompt caching** on and save. 3. Send a turn with debug logging on. The `[OpenAI] Enabling OpenRouter prompt caching` line (`openai.provider.ts:1049`) never fires and the request body carries no `cache_control`. ## Environment - Marinara Engine version: 2.4.5 (staging at 29ee24fc2) - Install type: source - OS + version: Fedora 44 - Browser or app shell: not browser-specific; verified by reading the code at the cited lines ## Logs, screenshots, or video Not applicable; the gate is visible at the cited lines. ## Additional context A second thing worth checking while fixing this: the field is sent as a top-level body key (`openai.provider.ts:1048`, pinned by `scripts/regressions/provider-compat.regression.ts:392-395`), while OpenRouter documents Anthropic-style caching as a per-content-part breakpoint inside `messages[].content[]`. Nothing in the tree proves the top-level form works. A capture of one real request and its `cachedPromptTokens` would settle it. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:03:24 +07:00
Author
Owner

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

Owner: @SpicyMarinara, with Codex implementing this issue as part of the requested sweep in draft PR #6230 against staging. I checked the open PRs and issue-linked work before starting; no competing open PR was found.

<!-- gh-comment-id:5677751416 --> @SpicyMarinara commented on GitHub (Sep 15, 2026): Owner: @SpicyMarinara, with Codex implementing this issue as part of the requested sweep in draft PR #6230 against `staging`. I checked the open PRs and issue-linked work before starting; no competing open PR was found.
Author
Owner

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

Merged in #6230 to staging (c6685f7034).

OpenRouter prompt caching now honors the connection provider through proxy base URLs. Disabled caching and generic custom-provider controls remain covered. The HTTP regression verifies both request paths. OpenRouter’s supported automatic cache_control field is retained.

<!-- gh-comment-id:5679123098 --> @SpicyMarinara commented on GitHub (Sep 15, 2026): Merged in #6230 to staging (c6685f7034d474bee00db124c4dc6398c5fc2bed). OpenRouter prompt caching now honors the connection provider through proxy base URLs. Disabled caching and generic custom-provider controls remain covered. The HTTP regression verifies both request paths. OpenRouter’s supported automatic cache_control field is retained.
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#3465
No description provided.