From ea902429f2c3ce6be60e8e925a49d777527d950c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B0=BD=EC=9A=B1?= Date: Wed, 25 Feb 2026 07:09:46 -0800 Subject: [PATCH] fix: exclude prompt_cache_key for Gemini API requests Gemini's OpenAI-compat endpoint rejects unknown fields. Only send prompt_cache_key to OpenAI-native endpoints. --- pkg/providers/openai_compat/provider.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index a8d244d4a..087d3506e 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -115,8 +115,12 @@ func (p *Provider) Chat( // with the same key and reuse prefix KV cache across calls. // The key is typically the agent ID — stable per agent, shared across requests. // See: https://platform.openai.com/docs/guides/prompt-caching + // Prompt caching is only supported by OpenAI-native endpoints. + // Gemini and other providers reject unknown fields, so skip for non-OpenAI APIs. if cacheKey, ok := options["prompt_cache_key"].(string); ok && cacheKey != "" { - requestBody["prompt_cache_key"] = cacheKey + if !strings.Contains(p.apiBase, "generativelanguage.googleapis.com") { + requestBody["prompt_cache_key"] = cacheKey + } } jsonData, err := json.Marshal(requestBody)