fix: skip prompt_cache_key for Gemini provider#796
Open
friday-james wants to merge 2 commits intosipeed:mainfrom
Open
fix: skip prompt_cache_key for Gemini provider#796friday-james wants to merge 2 commits intosipeed:mainfrom
friday-james wants to merge 2 commits intosipeed:mainfrom
Conversation
The prompt_cache_key field is an OpenAI-specific feature for prefix-based prompt caching. When sent to other providers like Gemini that use the OpenAI-compatible HTTP provider, it causes a 400 error because Gemini's API rejects unknown fields. This adds a supportPromptCache flag to the provider struct, enabled only for the OpenAI protocol, so the field is no longer sent to providers that don't support it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The prompt_cache_key field is accepted by most OpenAI-compatible providers, but Gemini rejects unknown fields in the request body, causing a 400 error. This adds a supportPromptCache flag to the HTTP provider, enabled for all providers except Gemini. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prompt_cache_keyfield is accepted by most OpenAI-compatible providers, but Gemini rejects unknown fields in the request body, causing a 400 error:Unknown name "prompt_cache_key": Cannot find fieldsupportPromptCacheflag to the HTTP provider, enabled for all providers except GeminiChanges
pkg/providers/openai_compat/provider.go: AddedsupportPromptCachefield and setter; gatedprompt_cache_keyon the flagpkg/providers/http_provider.go: ExposedSetSupportPromptCacheon the wrapperpkg/providers/factory_provider.go: Enabled the flag for all HTTP providers exceptgeminiTest plan
picoclaw agent -m "test" --model gemini-2.0-flash— should no longer get 400 errorpicoclaw agent -m "test" --model <other-model>— should still sendprompt_cache_key🤖 Generated with Claude Code