fix(openai): make store opt-in so it stops leaking to non-OpenAI backends (#4757)

This commit is contained in:
Yunsu
2026-04-13 21:53:22 +05:30
committed by GitHub
parent 4180409b09
commit 7b395f3bf7
3 changed files with 68 additions and 8 deletions
+6 -1
View File
@@ -29,7 +29,7 @@ class OpenAIConfig(BaseLlmConfig):
openrouter_base_url: Optional[str] = None,
site_url: Optional[str] = None,
app_name: Optional[str] = None,
store: bool = False,
store: Optional[bool] = None,
# Response monitoring callback
response_callback: Optional[Callable[[Any, dict, dict], None]] = None,
):
@@ -53,6 +53,11 @@ class OpenAIConfig(BaseLlmConfig):
openrouter_base_url: OpenRouter base URL, defaults to None
site_url: Site URL for OpenRouter, defaults to None
app_name: Application name for OpenRouter, defaults to None
store: Whether to store the conversation on OpenAI's server. Opt-in;
defaults to None (not sent). Set to True or False only if you
want the value forwarded to the OpenAI API. Leaving it None
avoids leaking the field into OpenAI-compatible backends that
reject unknown fields (Gemini, Groq, vLLM, etc.).
response_callback: Optional callback for monitoring LLM responses.
"""
# Initialize base parameters
+6 -5
View File
@@ -126,11 +126,12 @@ class OpenAILLM(LLMBase):
params.update(**openrouter_params)
else:
openai_specific_generation_params = ["store"]
for param in openai_specific_generation_params:
if hasattr(self.config, param):
params[param] = getattr(self.config, param)
# Only send OpenAI-specific parameters when the user has explicitly
# configured them. OpenAI-compatible backends (Gemini, Groq, vLLM, etc.)
# reject unknown fields, so `store` must be opt-in, not opt-out.
if self.config.store is not None:
params["store"] = self.config.store
if response_format:
params["response_format"] = response_format
if tools: # TODO: Remove tools if no issues found with new memory addition logic