#17462: fix(cache): enable cache retention for Google Vertex AI (#15525)
agents
stale
size: S
Cluster:
Bedrock and Caching Improvements
## 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
#22303: fix: extend cacheRetention auto-injection and runtime pass-through ...
by snese · 2026-02-21
79.1%
#12624: feat: add google-vertex embedding provider for Vertex AI ADC auth
by swseo92 · 2026-02-09
78.4%
#17560: fix: Anthropic Prompt Caching Not Working - Missing cache_control H...
by MisterGuy420 · 2026-02-15
77.4%
#19246: feat(media): add Google Vertex AI media provider
by ronaldslc · 2026-02-17
76.4%
#21491: fix: classify Google 503 UNAVAILABLE as transient failover [AI-assi...
by ZPTDclaw · 2026-02-20
75.3%
#17470: feat(cache): per-agent params for cacheRetention control (#17112)
by rrenamed · 2026-02-15
74.4%
#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatib...
by Kansodata · 2026-02-20
74.0%
#20866: fix: disable prompt caching for non-Anthropic Bedrock models
by pierreeurope · 2026-02-19
73.8%
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
73.7%
#14744: fix(context): key MODEL_CACHE by provider/modelId to prevent collis...
by lailoo · 2026-02-12
72.8%