Skip to content

fix: improve Gemini caching through OpenRouter#36070

Open
AbdoKnbGit wants to merge 1 commit into
anomalyco:devfrom
AbdoKnbGit:openrouter-gemini-cache
Open

fix: improve Gemini caching through OpenRouter#36070
AbdoKnbGit wants to merge 1 commit into
anomalyco:devfrom
AbdoKnbGit:openrouter-gemini-cache

Conversation

@AbdoKnbGit

@AbdoKnbGit AbdoKnbGit commented Jul 9, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36069

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Gemini requests through OpenRouter were not using the explicit cache breakpoints already supported by OpenCode.

This enables the existing cache-control behavior for OpenRouter Gemini models and includes the OpenCode session ID in OpenRouter session_id field to improve sticky routing and cache reuse.

How did you verify your code works?

Ran bun test test/provider/transform.test.ts from packages/opencode with 295 tests passing.

I also inspected the generated OpenRouter request and confirmed it includes the expected cache_control metadata and top-level session_id.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PR Found:

PR #35982: fix(provider): improve prompt caching
#35982

This PR is closely related as it also addresses prompt caching improvements at the provider level. While this current PR (#36070) specifically focuses on enabling Gemini caching through OpenRouter with session ID inclusion, PR #35982 appears to be a broader provider-level caching improvement that may overlap in scope or provide relevant context.

@AbdoKnbGit AbdoKnbGit force-pushed the openrouter-gemini-cache branch from 44a11d5 to 4bd7b36 Compare July 9, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve prompt caching for Gemini models on OpenRouter

1 participant