Skip to content

fix: improve Gemini caching through OpenRouter - #36070

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

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

Conversation

@AbdoKnbGit

@AbdoKnbGitAbdoKnbGit 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

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
AbdoKnbGitforce-pushed the openrouter-gemini-cache branch from 44a11d5 to 4bd7b36CompareJuly 9, 2026 12:55
@AbdoKnbGit
AbdoKnbGitforce-pushed the openrouter-gemini-cache branch from dc71ec6 to 4bd7b36CompareJuly 10, 2026 17:12
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
CreatorGhost added a commit to CreatorGhost/TheCode that referenced this pull request Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve prompt caching for Gemini models on OpenRouter

1 participant

@AbdoKnbGit