← Back to PRs

#17462: fix(cache): enable cache retention for Google Vertex AI (#15525)

by rrenamed open 2026-02-15 19:50 View on GitHub →
agents stale size: S
## Summary Fixes #15525. Vertex AI users get no prompt caching because `resolveCacheRetention()` only checks `provider === "anthropic"` and `isCacheTtlEligibleProvider()` excludes `google-vertex`. Since Vertex AI uses the Anthropic Messages API natively, it supports the same `cacheRetention` stream option. ## Root Cause In `extra-params.ts`, the provider guard rejects everything except `"anthropic"`: ```ts if (provider !== "anthropic") { return undefined; } ``` In `cache-ttl.ts`, the eligibility check only allows `"anthropic"` and `"openrouter"` with anthropic models: ```ts if (normalizedProvider === "anthropic") { return true; } ``` ## Fix Add `google-vertex` to both provider checks: ```ts // extra-params.ts if (provider !== "anthropic" && provider !== "google-vertex") { ``` ```ts // cache-ttl.ts if (normalizedProvider === "anthropic" || normalizedProvider === "google-vertex") { ``` Two-line change across two files. No new dependencies. ## Test plan - [x] e2e test: `cacheRetention` applied for `google-vertex` provider - [x] e2e test: `cacheRetention` NOT applied for non-Anthropic providers - [x] Unit tests for `isCacheTtlEligibleProvider` covering all providers + case insensitivity ## Local Validation - `pnpm build` ✅ - `pnpm check` (format + tsgo + lint) ✅ - Relevant test suites pass ✅ ## Contribution Checklist - [x] Focused scope — single fix per PR - [x] Clear "what" + "why" in description - [x] AI-assisted (Claude) — reviewed and tested by human - [x] Local validation run (`pnpm build && pnpm check`) *AI-assisted (Claude). Reviewed and tested by human.* <!-- greptile_comment --> <h3>Greptile Summary</h3> Enables prompt caching for Google Vertex AI by adding `google-vertex` to provider eligibility checks in two functions (`resolveCacheRetention` in `extra-params.ts:51` and `isCacheTtlEligibleProvider` in `cache-ttl.ts:14`). Since Vertex AI uses the Anthropic Messages API natively (as confirmed by `api: "anthropic"` in tests), it supports the same `cacheRetention` stream option. - Fixes missing cache retention for `google-vertex` provider - Comprehensive test coverage: e2e tests verify `cacheRetention` applied correctly for `google-vertex` and rejected for non-eligible providers - Unit tests cover all provider cases including case-insensitivity - Implementation is minimal and focused on the specific issue <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The changes are minimal (two provider checks updated), well-tested with comprehensive e2e and unit tests, and technically correct since Google Vertex AI uses the Anthropic Messages API natively. The fix is isolated to cache retention logic with no side effects on other functionality. - No files require special attention <sub>Last reviewed commit: afe01c7</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs