-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: remove explicit cache_control for Google models in OpenRouter (#4487) #4488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…4487) - Remove all Google models from OPEN_ROUTER_PROMPT_CACHING_MODELS set - This resolves 3+ minute lag when using google/gemini-2.5-pro-preview - OpenRouter still provides automatic implicit ephemeral caching for these models - Updated tests to handle intentional exclusion of Google models from explicit caching Fixes #4487
- Replace hardcoded exclusion list with simple Google model filter - Keep original validation logic but make it more maintainable - Still ensures all our caching models are supported by OpenRouter - Still verifies we exclude all Google models from explicit caching
- Variable was defined but never used - Keeps the test logic clean and focused
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, now we just wait for the tests
|
@cte can you take a look as well? Not really sure what the implications are of removing these from cached models. Do we still need the code here? Roo-Code/src/api/providers/openrouter.ts Lines 100 to 101 in 483d951
|
|
It seems that these models are now under implicit caching, @hannesrudolph confirmed that the caching is still enabled for these. I'm not sure if there's any benefits to explicit caching at this point. Edit: here's the documentation from OpenRouter: https://openrouter.ai/docs/features/prompt-caching So Gemini 1.5 might still benefit from the headers. |
- More surgical approach - only exclude the specific problematic model - Keep other Google models in caching (they work fine) - Add comment explaining the exclusion with issue reference - Update test to only exclude the specific model This targets just the model causing 3+ minute lag while preserving caching benefits for other Google models that work properly.
|
I have rolled the PR back to just changes related to |

Related GitHub Issue
Closes: #4487
Description
This PR fixes the 3+ minute lag issue when using
google/gemini-2.5-pro-previewthrough OpenRouter by removing explicitcache_controlflags for this specific model.Key implementation details:
google/gemini-2.5-pro-previewfrom theOPEN_ROUTER_PROMPT_CACHING_MODELSset inpackages/types/src/providers/openrouter.ts"cache_control": { "type": "ephemeral" }flags being added to requestsReviewers should pay attention to:
google/gemini-2.5-pro-previewmodel is affected - all other models continue to work as beforeTest Procedure
Unit Tests:
Manual Testing:
google/gemini-2.5-pro-previewmodel through OpenRouterTesting Environment:
Type of Change
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test- relevant provider tests passing).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
Not applicable - this is a performance fix with no UI changes.
Documentation Updates
This change is internal to the caching implementation and doesn't affect user-facing behavior beyond improved performance.
Additional Notes
Model affected:
google/gemini-2.5-pro-preview- No longer uses explicit cache_control (prevents 3+ minute lag)Models NOT affected (continue to use explicit caching as before):
google/gemini-2.5-flash-preview,google/gemini-2.0-flash-001, etc.)Impact:
google/gemini-2.5-pro-previewGet in Touch
I'm available through GitHub for any questions about this PR.
Important
Remove explicit cache control for Google models in
openrouter.tsto fix lag issue, updating tests accordingly.OPEN_ROUTER_PROMPT_CACHING_MODELSinopenrouter.tsto fix lag issue.openrouter.spec.tsto exclude Google models from caching tests.This description was created by
for a904d67. You can customize this summary. It will automatically update as commits are pushed.