You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Gemini and Vertex prompt cache drops out due to 4m warming interval and missing cachedContent #43628
Gemini and Google Cloud Vertex AI prompt caches experience 100% cache misses during multi-turn sessions when paused for ~3.5 minutes due to the provider's ephemeral in-memory cache TTL and lack of explicit cachedContent lowering in the Gemini protocol.
The default session warming interval was set to 4 minutes, which fires after Google's ~3 to 5 minute ephemeral cache window has already evicted the prefix.
Plugins
None
OpenCode version
v2 (0.0.0-dev)
Steps to reproduce
Run a multi-turn session with google-vertex/gemini-3.7-flash or google/gemini-2.5-flash where context exceeds 32k tokens.
Pause for ~3.5 minutes between turns.
Observe that the subsequent turn suffers a 100% prompt cache miss because the default 4-minute warming timer had not yet fired.
This appears to be a feature request, but it does not use the required Feature Request issue template. Please resubmit using the template, which requires: a title starting with [FEATURE]:, a verification checkbox, and a proper description of the problem/need.
The current title does not start with [FEATURE]: as required for feature requests.
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
changed the title [-]ai: improve Gemini and Vertex prompt cache efficiency with explicit cachedContent and keep-alive warmup[/-][+]Gemini and Vertex prompt cache drops out due to 4m warming interval and missing cachedContent[/+]on Aug 20, 2026
Thank you for updating the issue! It now meets our contributing guidelines. We appreciate the clear bug report with steps to reproduce, version, and system info.
Adding session level evidence for the Vertex Gemini dropout. Tested route google-vertex/gemini-3.8-flash on opencode 2.0.22, auth through Application Default Credentials.
Method: read all 29 assistant turns for one session straight from the local session database, recording provider, model, variant, input tokens, cache read tokens, cache write tokens, output tokens, thinking signatures, and timestamps.
Results:
Cache write equals 0 on all 29 turns, so this route relies purely on provider side implicit caching.
7 of 29 turns billed the full context fresh with 0 cached, inputs from 24k to 61k.
The other 22 turns hit normally.
Misses show no link to time gaps. Gaps of 3 seconds miss while a gap of 297 seconds hits.
Misses show no link to thinking signatures, reply sizes, or tool use. One miss had no tool calls at all, only thinking plus a short reply.
No wall or plugin activity fired during the session, and no instruction files changed that day.
Provider, model, and variant are identical on every turn.
Wider comparison from the same database: miss rates of 1.9 percent and 2.8 percent on opencode provider models across thousands of turns, 0.3 percent on another model across 1500 turns, against 29 percent and 21 percent on Vertex Gemini 3.8 and 3.7 across about 60 turns. No explicit cache writes on any route, so the gap sits provider side.
First turn miss is the normal cold start and is excluded from the above. Full per turn table available on request.
In v2, session warming is opt-in. With "warming": true it uses a 4-minute idle interval by default, as described in the warming docs. That default works for providers with a ~5-minute cache TTL, but Google's implicit cache can expire sooner. The interval is configurable, so for Gemini or Vertex you can warm more often today:
{
"warming": {
"interval": "2 minutes"
}
}
For explicit caching, the Gemini protocol already passes through a cachedContent you provide. OpenCode doesn't create or manage Google cachedContents for you, though.
So I'm treating this as a feature request with two parts:
warming defaults that depend on the provider (e.g. a shorter interval for google / google-vertex)
automatic explicit context caching (cachedContent) for Gemini
Activity
github-actions commentedon Aug 20, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:, a verification checkbox, and a proper description of the problem/need.[FEATURE]:as required for feature requests.Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
[-]ai: improve Gemini and Vertex prompt cache efficiency with explicit cachedContent and keep-alive warmup[/-][+]Gemini and Vertex prompt cache drops out due to 4m warming interval and missing cachedContent[/+]github-actions commentedon Aug 20, 2026
Thank you for updating the issue! It now meets our contributing guidelines. We appreciate the clear bug report with steps to reproduce, version, and system info.
kxng0109 commentedon Oct 9, 2026
Adding session level evidence for the Vertex Gemini dropout. Tested route google-vertex/gemini-3.8-flash on opencode 2.0.22, auth through Application Default Credentials.
Method: read all 29 assistant turns for one session straight from the local session database, recording provider, model, variant, input tokens, cache read tokens, cache write tokens, output tokens, thinking signatures, and timestamps.
Results:
Cache write equals 0 on all 29 turns, so this route relies purely on provider side implicit caching.
7 of 29 turns billed the full context fresh with 0 cached, inputs from 24k to 61k.
The other 22 turns hit normally.
Misses show no link to time gaps. Gaps of 3 seconds miss while a gap of 297 seconds hits.
Misses show no link to thinking signatures, reply sizes, or tool use. One miss had no tool calls at all, only thinking plus a short reply.
No wall or plugin activity fired during the session, and no instruction files changed that day.
Provider, model, and variant are identical on every turn.
Wider comparison from the same database: miss rates of 1.9 percent and 2.8 percent on opencode provider models across thousands of turns, 0.3 percent on another model across 1500 turns, against 29 percent and 21 percent on Vertex Gemini 3.8 and 3.7 across about 60 turns. No explicit cache writes on any route, so the gap sits provider side.
First turn miss is the normal cold start and is excluded from the above. Full per turn table available on request.
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report, @major!
In v2, session warming is opt-in. With
"warming": trueit uses a 4-minute idle interval by default, as described in the warming docs. That default works for providers with a ~5-minute cache TTL, but Google's implicit cache can expire sooner. The interval is configurable, so for Gemini or Vertex you can warm more often today:{ "warming": { "interval": "2 minutes" } }For explicit caching, the Gemini protocol already passes through a
cachedContentyou provide. OpenCode doesn't create or manage GooglecachedContentsfor you, though.So I'm treating this as a feature request with two parts:
google/google-vertex)cachedContent) for GeminiThe maintainers will consider it.