From 99866e6bfc57983036a98937e7052aa7c0774159 Mon Sep 17 00:00:00 2001 From: Mert Toslali Date: Tue, 24 Feb 2026 12:50:52 -0500 Subject: [PATCH] Fix top_p: null still sent in API requests after #385 PR #385 made top_p optional and defaulted it to None in LLMConfig, but openai.py still unconditionally includes top_p in the request params dict. This sends "top_p": null to providers like AWS Bedrock that don't strip null values, causing 400 errors. Only include top_p in params when it is explicitly set. Fixes #414 Co-Authored-By: Claude Opus 4.6 --- openevolve/llm/openai.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openevolve/llm/openai.py b/openevolve/llm/openai.py index 7477e5b349..f7d0648de2 100644 --- a/openevolve/llm/openai.py +++ b/openevolve/llm/openai.py @@ -155,9 +155,11 @@ async def generate_with_context( "model": self.model, "messages": formatted_messages, "temperature": kwargs.get("temperature", self.temperature), - "top_p": kwargs.get("top_p", self.top_p), "max_tokens": kwargs.get("max_tokens", self.max_tokens), } + top_p = kwargs.get("top_p", self.top_p) + if top_p is not None: + params["top_p"] = top_p # Handle reasoning_effort for open source reasoning models. reasoning_effort = kwargs.get("reasoning_effort", self.reasoning_effort)