Skip to content

V2 drops prompt cache affinity for OpenRouter and OpenAI Chat #42246

Closed as not planned

Description

@phall1

Description

V2 creates a stable prompt cache key from the session ID, but that key does not reach every route

The session runner only sets providerOptions.openai.promptCacheKey. This works for OpenAI Responses, but:

  • OpenRouter reads providerOptions.openrouter.promptCacheKey, so V2 OpenRouter requests omit prompt_cache_key.
  • Native OpenAI Chat does not lower providerOptions.openai.promptCacheKey into the Chat Completions body.

As a result, consecutive requests in the same V2 session can lose provider cache affinity even though their prompt history has a reusable prefix.

Potentially related or part of #39907, which described stable OpenRouter session cache keys.

Plugins

No response

OpenCode version

dev at 37fe5c8

Steps to reproduce

  1. Create two consecutive V2 requests in the same session using an OpenRouter model.
  2. Inspect the prepared OpenRouter request body.
  3. Observe that prompt_cache_key is absent because the runner sets the key under the openai namespace while the route reads openrouter.
  4. Repeat using native OpenAI Chat Completions.
  5. Observe that the request carries providerOptions.openai.promptCacheKey, but the prepared Chat body omits prompt_cache_key.

Expected: supported routes receive the same stable session-derived cache key on every turn.

Generic OpenAI-compatible providers should remain unchanged because they may reject unsupported OpenAI-specific fields.

Screenshot and/or share link

n/a - but visible in request bodies

Operating System

No response

Terminal

No response

Activity

  1. phall1 commented on Sep 9, 2026

    @phall1
    Author

    Closing as implemented in #39907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions